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?
h1 , m1 , h2 , m2 , k = map(int , input().split())
diff = (h2-h1)*60 + abs(m2-m1)
ans = diff - k
print(diff,ans)
if ans <=0:
	print(0)
else:
	print(ans)

h1 , m1 , h2 , m2 , k = map(int , input().split())
hr = h2-h1
m = m2-m1
#print(hr,m)
diff = hr*60+m
ans = diff - k
#print(diff1,diff2,diff,ans)
if ans <=0:
	print(0)
else:
	print(ans)