HM = list(map(int, input().split()))

hours = HM[2]-HM[0]

minutes = HM[3]-HM[1]

K = HM[4]

totalTimes = hours*60+minutes

print((totalTimes-K))
H1, M1, H2, M2, K = list(map(int, input().split()))

print((60*(H2-H1)+(M2-M1)-K))
HM = list(map(int, input().split()))
hours = HM[2] - HM[0]
minutes = HM[3] - HM[1]
K = HM[4]
totalTimes = hours * 60 + minutes
print((totalTimes - K))

H1, M1, H2, M2, K = list(map(int, input().split()))
print((60 * (H2 - H1) + (M2 - M1) - K))

-HM = list(map(int, input().split())) -hours = HM[2] - HM[0] -minutes = HM[3] - HM[1] -K = HM[4] -totalTimes = hours * 60 + minutes -print((totalTimes - K)) +H1, M1, H2, M2, K = list(map(int, input().split())) +print((60 * (H2 - H1) + (M2 - M1) - K))