h1, m1, h2, m2, k = list(map(int, input().split()))

l = (60 * h2 + m2) -(60 * h1 + m1)

ans = l - k

print(ans)
a,b,c,d,e=list(map(int,input().split()))

l=(60*c+d)-(60*a+b)

ans=l-e

print(ans)
h1, m1, h2, m2, k = list(map(int, input().split()))
l = (60 * h2 + m2) - (60 * h1 + m1)
ans = l - k
print(ans)

a, b, c, d, e = list(map(int, input().split()))
l = (60 * c + d) - (60 * a + b)
ans = l - e
print(ans)

-h1, m1, h2, m2, k = list(map(int, input().split())) -l = (60 * h2 + m2) - (60 * h1 + m1) -ans = l - k +a, b, c, d, e = list(map(int, input().split())) +l = (60 * c + d) - (60 * a + b) +ans = l - e