In this problem, we use the 24-hour clock.  Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
#a = input()
a, b, c, d, e = map(int, input().split())
# get a string

# output
start = a*60+b
end = c*60+d
result = end - start
print(result)
a, b, c, d, e = map(int, input().split())
# get a string

# output
start = a*60+b
end = c*60+d
result = end - start - e
print(result)