import sys



H1,M1,H2,M2,K = list(map(int, sys.stdin.readline().split()))



print(((H2 - H1) * 60 + M2 - M1 - K))

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

print(((H2*60 + M2 - K) - (H1*60 + M1)))
import sys

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

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

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