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

res=max(h2*60+m2-h1*60-m1-k,0)

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

res=h2*60+m2-h1*60-m1-k

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

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

-res = max(h2 * 60 + m2 - h1 * 60 - m1 - k, 0) +res = h2 * 60 + m2 - h1 * 60 - m1 - k