a = input()
b = input()
x = a.split(':')
y = b.split(':')
c = int(x[0]) * 3600 + int(x[1]) * 60 + int(x[2]) - int(y[0])*3600 - int(y[1])*60 - int(y[2])
print(c)
/**************************************************************
Problem: 1101
User: admin
Language: Python
Result: Accepted
Time:188 ms
Memory:34480 kb
****************************************************************/