peterverebics/CodeNet_Python_118 huggingface dataset:
h1, m1, h2, m2, k = map(int, input().split())
s = (h2 * 60 + m2) - (h1 * 60 + m1)
if s > k:
    print(s - k)
else:
    print(0)
# -*- coding: utf-8 -*-

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

print(max((H2*60+M2) - (H1*60+M1) - K, 0))
h1, m1, h2, m2, k = map(int, input().split())
start = h1*60+m1
end = h2*60+m2
print(end-start-k)
import math

H1,M1,H2,M2,K=map(int,input().split())
T=(H2*60+M2)-(H1*60+M1)
if T-K<=0:
    T=0
else:
    T=T-K
print(T)
x = input().split()

h1 = int(x[0])
m1 = int(x[1])
h2 = int(x[2])
m2 = int(x[3])
k = int(x[4])

print((h2-h1)*60+m2-m1-k)
a,b,c,d,k = map(int,input().split())
h = c-a
mn = d-b

time = h*60+mn
ans = time-k
print(ans)
o1, o2, n1, n2, k = map(int, input().split())


o_all = o1*60 + o2
n_all = n1*60 + n2

print(n_all-o_all-k)
h1, m1, h2, m2, k = map(int, input().split())

t = (m2 - m1) + (h2 - h1) * 60
ans = t - k

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

time1 = H1 * 60 + M1
time2 = H2 * 60 + M2
time3 = time2 - K

if time3 < time1: print(0)
else: print(time3 - time1)
H1, M1, H2, M2, K = [int(s) for s in input().split()]
if H2 < H1:
    H2 += 24
elif H2 == H1 and M1 > M2:
    H2 += 24
print(int(H2 * 60 + M2 - (H1 * 60 + M1) - K))
h1, m1, h2, m2, k = map(int, input().split())
time1 = 60*h1 + m1
time2 = 60*h2 + m2
print(time2 - time1 - k)
h1,m1,h2,m2,k = map(int,input().split())
t1=60*h1+m1
t2=60*h2+m2
print(t2-t1-k)
import sys
input = sys.stdin.readline
import math
a,b,c,d,e = map(int,input().split())
print(max((c-a)*60+(d-b)-e,0))
h1,m1,h2,m2,k=map(int,input().split())
ans2=h2*60+m2
ans1=h1*60+m1
print(ans2-ans1-k)
# 2020/05/30
# NOMURA プログラミングコンテスト 2020 - A

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

# Calc
hm1 = h1 * 60 + m1
hm2 = h2 * 60 + m2
ans = hm2 - hm1 - k

# Output
print(ans)
h1, m1, h2, m2, k = map(int, input().split())

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

if(a>k):
  print(a-k)
else :
  print(0)
h1, m1, h2, m2, k = map(int, input().split())

h = h2 - h1
m = m2 - m1

t = h*60 + m

print(t - k)
h1, m1, h2, m2, k = map(int, input().split())
start = h2 * 60 + m2 - k
time = h1 * 60 + m1
ans = start - time
print(ans)
H1, M1, H2, M2, K = map(int, input().split())
print((H2 * 60 + M2) - (H1 * 60 + M1) - K)
H1,M1,H2,M2,K=map(int,input().split())
T1=60*H1+M1
T2=60*H2+M2
T=T2-T1-K
if T<0:
    T=0
print(T)
h_1,m_1,h_2,m_2,k=map(int,input().split())
print(60*(h_2-h_1)+m_2-m_1-k)
#list(map(int,input().split()))
a,b,c,d,e=list(map(int,input().split()))
print(c*60+d-a*60-b-e)
h1, m1, h2, m2, k = map(int, input().split())

print((h2-h1)*60 + (m2-m1) - k)
h = list(map(int, input().split()))
h1 = h[0]
m1 = h[1]
h2 = h[2]
m2 = h[3]
k = h[4]

lh = h2 - h1
if lh < 0:
    lh = lh + 24
lm = m2 - m1

if lh == 0 and lm < 0:
    lm = lm + 24*60

l = lh * 60 + lm - k
    

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

st = h1 * 60 + m1
en = h2 * 60 + m2

print(max(0, en - st - k))
h1, m1, h2, m2, k = map(int, input().split())

hm1 = h1*60+m1
hm2 = h2*60+m2

print(hm2-hm1-k)
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d, e = list(map(int, readline().split()))

    x = a * 60 + b
    y = c * 60 + d
    z = y - x

    print(z-e)


if __name__ == '__main__':
    main()
h1,m1,h2,m2,k = map(int,input().split())

start = 60*h1+m1
end = 60*h2+m2
res = (end-start-k)


print(res)
h,m,H,M,k = map(int,input().split())

t1 = 60*h + m
t2 = 60*H + M

ans = t2 - t1 - k
print(ans)
H1, M1, H2, M2, K = map(int, input().split())
Stayup_Time = (H2 * 60 + M2) - (H1 * 60 + M1)
Notstudy_Time = Stayup_Time - K
print(Notstudy_Time)
h = list(map(int, input().split()))

if h[1] < h[3]:
    print((h[2]-h[0])*60+h[3]-h[1]-h[4])
else:
    print((h[2]-h[0]-1)*60+60-h[1]+h[3]-h[4])
a = list(map(int,input().split()))

x = a[0]*60 + a[1]
y = a[2]*60 + a[3]

z = y - x

r = z - a[4]

print(r)
h = list(map(int, input().split()))
tmp1 = h[0] * 60 + h[1]
tmp2 = h[2] * 60 + h[3]
ans = tmp2 - tmp1
print(ans - h[4])
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    h1,m1,h2,m2,k = mi()
    res = convert(h2,m2) - convert(h1,m1) - k
    print(res)

def convert(h,m):
    return h*60 + m

if __name__ == "__main__":
    resolve()
H,M,h,m,K=map(int,input().split())
X=(h*60+m)-(H*60+M)
print(X-K)
h1,m1,h2,m2,K=map(int, input().split())

x1=h1*60+m1
x2=h2*60+m2

print(x2-x1-K)
h,m,hh,mm,k = map(int,input().split())
x = hh*60-h*60+mm-m
print(x-k)
H, M, h, m, K = map(int, input().split())

print( max(0, 60*(h-H) + m - M - K) )
sh, sm, eh, em, K = map(int, input().split())

time = 60*(eh-sh) + em - sm
print(time - K)
import sys

def input():
    return sys.stdin.readline()[:-1]


H1, M1, H2, M2, K = map(int, input().split())
start_time = H1*60 + M1
end_time = H2*60 + M2

print(end_time - start_time - K)
h1, m1, h2, m2, k = map(int, input().split())

start = h1*60 + m1
end = h2*60 + m2

print(end- start - k)
a,b,c,d,e=map(int,input().split())
n=(c-a)*60+(d-b)
print(n-e)
a,b,c,d,e=map(int,input().split())

f=c*60+d-a*60-b


if f-e>=0:
  print(f-e)
else:
  print(0)
def solve():
    H1,M1,H2,M2,K = map(int,input().split())
    M1 += H1 * 60
    M2 += H2 * 60
    print(M2-M1-K)

if __name__ == '__main__':
    solve()
h1, m1, h2, m2, k = map(int, input().split())
print((h2 - h1) * 60 + (m2 - m1) - k)
A,B,C,D,E = map(int,input().split())

print(max(0,-60*A-B+(60*C+D))-E)
def time_to_min(H, M):
  return H * 60 + M


def resolve():
  H1, M1, H2, M2, K= map(int, input().split(" "))
  start = time_to_min(H1, M1)
  end = time_to_min(H2, M2)
  print(end - start - K)

if __name__ == "__main__":
  resolve()
H1, M1, H2, M2, K = map(int, input().split())

H1 = H1 * 60
H2 = H2 * 60

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

HM1=H1*60+M1
HM2=H2*60+M2
print(max(HM2-HM1-K,0))
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h1,m1,h2,m2,k = mi()

s = 60 * h1 + m1
f = 60 * h2 + m2

ans = f-s-k

print(ans)
Ha,Ma,Hb,Mb,K = list(map(int,input().split()))

tmp = (Hb*60 + Mb) - (Ha*60 + Ma)

print(tmp-K)
#!/usr/bin/env python3
h1, m1, h2, m2, k = map(int, input().split())
print((h2 * 60 + m2) - (h1 * 60 + m1) - k)
# coding: utf-8


def solve(*args: str) -> str:
    h1, m1, h2, m2, k = map(int, args[0].split())
    return str((h2-h1)*60 + (m2-m1) - k)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
h1, m1, h2, m2, k = map(int, input().split())
time = (h2 * 60 + m2) - (h1 * 60 + m1)
print(max(time - k, 0))
h, m, h2, m2, k = map(int, input().split())
ans = (h2 * 60 + m2) - (h * 60 + m) - k
print(ans)
a,b,c,d,e = map(int,input().split())
p = a * 60 + b
q = c * 60 + d
r = q - p
print(r - e)
h1,m1,h2,m2,k = map(int, input().split())

bt = h1*60 + m1
at = h2*60 + m2

time = at - bt

print(time-k)
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum


def çözmek():
    h, m, H, M, K = map(int, input().split(" "))
    if H != 0:
        H = H * 60
    if h != 0:
        h = h * 60
    res = H + M - K - h - m
    print(res)
if __name__ == "__main__":
    çözmek()
def main():
    h1,m1,h2,m2,k = map(int,input().split())
    wake_up_minutes = (h2-h1) * 60 - m1 + m2
    study_start_minutes = max(0,wake_up_minutes - k)
    print(study_start_minutes)

if __name__ == '__main__':
    main()
A = list(map(int, input().split()))

print((A[2]*60+A[3])-(A[0]*60+A[1])-A[4])
H1,M1,H2,M2,K=map(int, input().split())
a=60*(H2-H1)
b=M2-M1
c=a+b
print(c-K)
h1, m1, h2, m2, k = map(int, input().split())

t = 60 * h2 + m2 - (60 * h1 + m1) - k

print(t)
h, m, h2, m2, k = map(int, input().split())

i = h2 * 60 + m2 - (h * 60 + m)

print(i-k)
h1,m1,h2,m2,k = map(int,input().split())

time = (h2 - h1) * 60 + (m2 - m1)
print(time - k)
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

h1,m1,h2,m2,k = mapi()
delta =m2+h2*60-(m1+h1*60)-k
print(delta)
h1,m1,h2,m2,k=map(int,input().split())
if h1==h2:
    print(m2-m1-k)
else:
    print((60-m1)+(h2-h1-1)*60-k+m2)
a, b, c, d, K = map(int,input().split())
print(max(0,(60*c+d - 60*a-b)-K))
h1,m1,h2,m2,k = map(int,input().split())
if h2 < h1:
    h2 += 24
if m2 < m1:
    m2 += 60
    h2 -= 1
print((h2-h1)*60+m2-m1-k)
H1, M1, H2, M2, K = map(int, input().split())

print((H2 * 60 + M2) - (H1 * 60 + M1) - K)
h,m,hh,mm,k = map(int,input().split())

wakeup = (hh-h)*60 + mm - m

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

H1,H2 = 60*H1,60*H2

AM = H1+M1
PM = H2+M2
ans = PM-AM-K
print(ans)
H1,M1,H2,M2,K=map(int, input().split())

min=(H2-H1)*60+M2-M1

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

time1 = H1*60 + M1
time2 = H2*60 + M2
time = time2 - time1

ans = time - K

print(max(ans, 0))
import sys
input = sys.stdin.readline

h1,m1,h2,m2,k=map(int,input().split())
H=(h2-h1)*60
M=m2-m1
time=H+M


if time-k >=0:
  print(time-k)
else:
    print(0)
h1, m1, h2, m2, k = map(int, input().split())
print(max((h2-h1)*60+m2-m1-k, 0))
h1, m1, h2, m2, k = [int(x) for x in input().split()]

ans = (h2 * 60 + m2) - (h1*60 + m1) - k

print(max(0, ans))
H,M,h,m,K=map(int,input().split())
print((h-H)*60+m-M-K)
h1, m1, h2, m2, k = map(int, input().split(" "))
print( ((h2-h1)*60+m2-m1)-k )
h1, m1, h2, m2, k =map(int, input().split())

ans = (h2-h1)*60+(m2-m1)-k
print(ans)
H1, M1, H2, M2, K = map(int, input().split())
h = H2 - H1
m = M2 - M1
T = h * 60 + m
print(T-K)
h1,m1,h2,m2,k=map(int,input().split())

ans=(h2-h1)*60+(m2-m1)
ans-=k

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

hm=(h2*60+m2)-(h1*60+m1)-k
print (hm)
H1,M1,H2,M2,K = map(int,input().split())
ans = 0
ans += (H2-H1) * 60
ans += M2 - M1
ans -= K
print(ans)
import datetime

if __name__ == "__main__":
    H1, M1, H2, M2, K = [int(a) for a in input().split()]
    dt_start = datetime.datetime(year=2020, month=5, day=30, hour=H1, minute=M1, second=00)
    dt_end= datetime.datetime(year=2020, month=5, day=30, hour=H2, minute=M2, second=00)
    up_time = dt_end - dt_start
    sec = up_time.total_seconds()  - K * 60
    print(int(sec/60))
import sys
input = lambda: sys.stdin.readline().rstrip()

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


if M2 - M1 >= 0:
    tmp = (H2-H1) * 60 + (M2-M1)
else:
    tmp = (H2-H1-1) * 60 + 60+M2-M1

print(tmp - K)
h1, m1, h2, m2, k = map(int, input().split())

hd = h2 - h1
if m1 > m2:
  hd -= 1
  m2 += 60
md = m2 - m1

m = hd * 60 + md

print(m-k)
h1, m1, h2, m2, k = map(int, input().split())
if m1 > m2:
    print(((h2 - 1) - h1) * 60 + (m2 + 60 - m1) - k) 
else:
    print((h2 - h1) * 60 + (m2 - m1) - k)
h1, m1, h2, m2, k = map(int, input().split())

a = (h2 - h1) * 60 + (m2 - m1)
print(a - k)
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())

h1,m1,h2,m2,k=reads()
limit=(h2-h1)*60+m2-m1
res=0
if limit-k>=0:
    limit-=k
else:limit=0
print(limit)
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 =[int(x) for x in input().split()]
minute = (h2*60+m2) - (h1*60+m1) - k
if minute <= 0:
    print(0)
else:
    print(minute)
h,m,a,b,k=map(int,input().split())
h_to_min = h * 60
a_to_min = a * 60
re1 = a_to_min - h_to_min
re2 = b - m
re = re1 + re2
print(re-k)
sh,sm,fh,fm,k = map(int,input().split())
h = 0
m = 0
ans = 0

if sm > fm:
    h = 60*(fh-sh)
    m = sm -fm
    ans = h - m - k
else:
    h = 60*(fh-sh)
    m = fm -sm
    ans = h + m - k  

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

ans = (h2*60+m2)-(h1*60+m1)-k
print(ans)
h1, m1, h2, m2, k = map(int, input().split())
time = (h2- h1)*60 + m2 - m1
settime = time-k
print(settime)
A, B, C, D, K = list(map(int,input().split()))
a = 60 * A + B
b = 60 * C + D
c = b - a
ans = c - K
print(ans)
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
a,b,c,d,k=map(int,input().split())
strt=a*60+b
end=c*60+d
print(end-k-strt)
h1, m1, h2, m2, k = map(int, input().split())

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

print(x-k)
h1, m1, h2, m2, k = list(map(int, input().split()))
print((h2 * 60 + m2) - (h1 * 60 + m1) - k)
H1, M1, H2, M2, K = map(int, input().split())

alltime = (H2-H1)*60 + M2-M1

print(alltime-K)
H1, M1, H2, M2, K = map(int, input().split())
print((H2-H1)*60 + (M2-M1) -K)
def main():
    h1, m1, h2, m2, k = map(int, input().split())
    time = (h2 - h1) * 60 - m1 + m2
    print(max(time - k, 0))


if __name__ == '__main__':
    main()
H1, M1, H2, M2, K = map(int, input().split())
T1, T2 = (H1 * 60 + M1), (H2 * 60 + M2)
print("{}".format((T2 - K) - T1))
H1,M1,H2,M2,K = map(int, input().split())

t1 = H1 * 60 + M1
t2 = H2 * 60 + M2

if t2 - t1 <= K:
    print(0)
else:
    print(t2-t1-K)
h1, m1, h2, m2, k = list(map(int, input().split()))

result = (h2 * 60 + m2) - (h1 * 60 + m1) - k
print(result)
H1,M1,H2,M2,K = map(int,input().split())
t = (H2*60 + M2) - (H1*60 + M1) - K
print(t)
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h1, m1, h2, m2, k = map(int,input().split())
    print(h2*60+m2-h1*60-m1-k)

if __name__=='__main__':
    main()
#スペース区切りの整数の入力
h1, m1, h2, m2, k = map(int, input().split())

asa = h1 * 60 + m1
yoru = h2 * 60 + m2 - k


if(yoru<=asa):
  print("0")
else:
  print(yoru-asa)
def main():
    h1, m1, h2, m2, k = map(int, input().split())
    x = 60 * h1 + m1
    y = 60 * h2 + m2 - k
    print(max(0, y - x))

if __name__ == '__main__':
    main()
H,M,K,T,S = map(int,input().split())
print(max(((K*60+T-H*60-M-S)+1440)%1440,0))
def find(H1,M1,H2,M2,K):
    left = H1*60+M1
    right = H2*60+M2
    remain = right-left-K
    return max(remain,0)
H1,M1,H2,M2,K = list(map(int,input().strip().split()))
print(find(H1,M1,H2,M2,K))
H1, M1, H2, M2, K = map(int,input().split())
HM1 = H1*60 + M1
HM2 = H2*60 + M2 - K
print(HM2 - HM1)
H1, M1, H2, M2, K = map(int, input().split())

T1 = H1 * 60 + M1
T2 = H2 * 60 + M2

print(T2 - T1 - K)
h,m,h2,m2,k = map(int,input().split())

end = h2*60+m2
stt = h*60+m

print(end-stt-k)
h, m, hh, mm, k = map(int, input().split())
print(hh*60 + mm - h*60 - m - k)
a = list(map(int,input().split()))
b = a[2] * 60 + a[3] - a[0] * 60 - a[1] - a[4]
print(b)
H1,M1,H2,M2,K = map(int,input().split())
print((H2-H1)*60+(M2-M1)-K)
H1,M1,H2,M2,K=map(int,input().split())
d=H1*60
g=H2*60
f=(g+M2)-(d+M1)-K
print(f)
H1,M1,H2,M2,K = map(int,input().split())
start = H1*60 + M1
finish = H2*60 + M2 - K

if finish - start >= 0:
  print(finish - start)
else:
  print(0)
H1, M1, H2, M2, K = map(int, input().split())
Hk, Mk = K//60, K%60
Htmp = H2 - Hk
Mtmp = M2 - Mk
if Mtmp < 0:
    Mtmp += 60
    Htmp -= 1
    
Htmp = Htmp - H1
Mtmp = Mtmp - M1
if Mtmp < 0:
    Mtmp += 60
    Htmp -= 1

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

H = H2 - H1
M = M2 - M1

answer = H*60 + M - K
print(answer)
list = input().split()
 
m1 = int(list[0])*60 + int(list[1])
m2 = int(list[2])*60 + int(list[3])
#print(m1,m2)
    
ans = m2 - m1
print(ans-int(list[4]))
h1,m1,h2,m2,k = map(int,input().split())

dm = m2 - m1
if h2 < h1:
    h2 +=24

if dm < 0:
    h2 -= 1
    dm = 60 + dm

print((h2 - h1)*60 + dm - k)
from datetime import*
a,b,c,d,k=map(int,input().split())
f=datetime
print((f(1,1,1,c,d)-f(1,1,1,a,b)).seconds//60-k)
H1, M1, H2, M2 , K = map(int, input().split())

t1 = 60*H1 + M1
t2 = 60*H2 + M2

print(t2 - t1 - K)
h,m,hh,mm,k=list(map(int,input().split()))

hm=h*60+m
hhmm=hh*60+mm

ans=hhmm-k-hm
print(ans)
H1, M1, H2, M2, K = map(int, input().split())

import datetime
dt1 = datetime.datetime(year=2020, month=5, day=29, hour=H1, minute=M1)
dt2 = datetime.datetime(year=2020, month=5, day=29, hour=H2, minute=M2)

tmp = dt2 - datetime.timedelta(minutes=K)
tmp2 = dt2 - dt1
ans = (tmp - dt1).total_seconds() / 60

if (tmp2.total_seconds()) <= 0:
        print(0)
        exit()
else:
        print(int(ans))
h1, m1, h2, m2, k = map(int, input().split())
print((h2*60 + m2) - (h1*60 + m1) - k)
h1,m1,h2,m2,k = list(map(int,input().split()))

h = h2-h1
m = m2-m1
minute = h*60 + m
ans = minute-k
if ans > 0 :
    print(ans)
else:
    print(0)
H, M , h, m, K = map(int, input().split())

during = (h-H)*60 + (m-M)
print(during-K)
H1, M1, H2, M2, K = map(int, input().split())
ans = 60*H2+M2 - (60*H1+M1) - K
print(ans)
if __name__ == "__main__":
    h1, m1, h2, m2, k = map(int, input().split())

    print(h2*60+m2-h1*60-m1-k)
H1, M1, H2, M2, K = map(int, input().split())
summin = (H2 * 60 + M2) - (H1 * 60 + M1) - K
print(summin)
H1, M1, H2, M2, K = map(int, input().split())

wake = H1*60 + M1
sleep = H2*60 + M2
time = int((sleep-wake))

print(time-K)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

m1 = m1 + h1*60
m2 = m2 + h2*60

ans = max(m2 - m1 - k, 0)

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

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

h = (h2 - h1)*60
m = m2 - m1

if m < 0:
  h = h - 60
  m = 60 + m

total = h + m

print(total-k)
import datetime

data = input().split(' ')
data = map(lambda x: int(x), data)

h1, m1, h2, m2, k = list(data)

wakeup = datetime.datetime(2000, 1, 1, hour=h1, minute=m1)
gotobed = datetime.datetime(2000, 1, 1, hour=h2, minute=m2)

study = datetime.timedelta(minutes=k)

result = gotobed  - wakeup - study
result = result.total_seconds() / 60
result = int(result)

print(result)
x1,y1,x2,y2,t=map(int,input().split())
print((x2-x1)*60+(y2-y1)-t)
h1,m1,h2,m2,k=map(int,input().split())
t=(60*h2+m2)-(60*h1+m1)
print(t-k)
h,m,H,M,K=map(int,input().split())
print(60*H+M-60*h-m-K)
h1,m1,h2,m2,k = map(int,input().split())
ans = 60 * (h2 - h1) + (m2 - m1) - k
print(ans)
h1, m1, h2, m2, K = map(int, input().split())

start = h1 * 60 + m1
goal = h2 * 60 + m2 - K

if start < goal:
    print(goal - start)
else:
    print(0)
H1,M1,H2,M2,K = (int(x) for x in input().split())
time = (H2 * 60 + M2)-(H1* 60 + M1) - K
print(time)
h1, m1, h2, m2, k = map(int, input().split())

m = (h2 - h1) * 60 + m2 - m1 - k
print(m)
H1,M1,H2,M2,K = map(int,input().split())

H = H2 - H1
M = M2 - M1

t = H * 60 + M - K

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

start = h2 * 60 + m2 - k
time = start - h1 * 60 - m1

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

print(min - k)
h1,m1,h2,m2,k = map(int,input().split())
print((h2-h1)*60+m2-m1-k)
H1, M1, H2, M2, K = map(int, input().split())

print((H2-H1)*60+(M2-M1)-K)
a, b, c, d, K = map(int, input().split())

hour = (c-a) * 60
min = d - b
ans = hour + min - K
print(ans)
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

h1,m1,h2,m2,k=map(int,input().split())
h=h2-h1
m=m2-m1
leng=h*60+m
print(leng-k)
h, m, h2, m2, k = map(int, input().split())


m1 = h * 60 + m
m2 = h2 * 60 + m2

if(m2 - m1):
    time = m2 - m1
else:
    time = 1440 - m1 + m2

ans = max(time - k, 0)
print(ans)
h1, m1, h2, m2, k = map(int, input().split())

hour = h2 - h1
minite = m2 - m1
print(hour*60+minite-k)
H1, M1, H2, M2, K = map(int, input().split())
x = (H2 - H1) * 60
y = M2 - M1
ans = x + y - K
print(ans)
H1, M1, H2, M2, K = map(int, input().split())

t1 = 60 * H1 + M1
t2 = 60 * H2 + M2

T = t2 - t1 - K
if T < 0:
  T += 24 * 60

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

time1 = 60*H1 + M1
time2 = 60*H2 + M2
time = time2-time1
ans = time - K
if ans < 0:
  print(0)
else:
  print(ans)
h1, m1, h2, m2, k = map(int, input().split())
print(max(0, (h2*60+m2) - (h1*60+m1) - k))
H_1, M_1, H_2, M_2, K = map(int,input().split(" "))
t1 = H_1*60 + M_1
t2 = H_2*60 + M_2
delta_t = t2 - t1
print(delta_t-K)
from sys import stdin
H1,M1,H2,M2,K = [int(x) for x in stdin.readline().rstrip().split()]
ans = (H2-(H1+1))*60
ans += (60-M1)
ans += M2
ans -= K
print(ans)
import sys
input=sys.stdin.readline
h1,m1,h2,m2,k=map(int,input().split())
h1=h1*60
h2=h2*60
m1+=h1
m2+=h2
print(m2-m1-k)
H1_M1_H2_M2_K = list(map(int, input().split(" ")))

H1 = H1_M1_H2_M2_K[0]
M1 = H1_M1_H2_M2_K[1]
H2 = H1_M1_H2_M2_K[2]
M2 = H1_M1_H2_M2_K[3]
K = H1_M1_H2_M2_K[4]

dif_H = H2 - H1
dif_M = M2 - M1

ans = (dif_H * 60 + dif_M - K)
print(ans)
(wake_h, wake_m, sleep_h, sleep_m, k) = list(map(int, input().split()))

wake_m_all = wake_h * 60 + wake_m
sleep_m_all = sleep_h * 60 + sleep_m
sleep_m_all -= k
print(sleep_m_all - wake_m_all)
h1,m1,h2,m2,k = map(int,input().split())

f=60*h1+m1
s=60*h2+m2

a=s-f


if k>a:
  print(0)
else:
  b=s-k
  print(b-f)
h1,m1,h2,m2,k=map(int,input().split())
w=h2*60+m2-(h1*60+m1)
print(w-k)
h1, m1, h2, m2, k = map(int, input().split())
if m2 >= m1:
    print((h2 - h1) * 60 + (m2 - m1) - k)
else:
    print((h2-1 - h1) * 60 + (m2 + 60 - m1) - k)
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

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

# = [list(map(int,input().split())) for _ in range(XXXX)]

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

start = 60*h1+m1
end = 60*h2+m2

waketime = end - start

if waketime >= k:
    print(waketime - k)
else:
    print(0)
a,b,c,d,e = map(int,(input().split()))
s = a*60+b
g = c*60+d
print(g-s-e)
a, b, c, d, e = map(int, input().split())
time = (c * 60 + d) - (a * 60 + b)
time = time + 24 * 60 if time < 0 else time
print((60 * c + d) - (60 * a + b) - e)
a = list(map(int, input().split()))
kishou = a[0] * 60 + a[1]
shuusin = a[2] * 60 + a[3]
print(shuusin - kishou - a[4])
h1, m1, h2, m2, k = map(int, input().split())
l1 = 60*h1 + m1
l2 = 60*h2 + m2
if(l1 > l2):
  l2 += 24*60
dl = l2 - l1
print(dl - k)
H1, M1, H2, M2, K = map(int, input().split())
A = 60*H1 + M1
B = 60*H2 + M2
print(max(B-A-K, 0))
h1,m1,h2,m2,k = map(int,input().split())
delt = 60*(h2-h1) + (m2-m1)
print(delt-k)
def main():
    array = list(map(int, input().split()))

    now = array[0]*60+array[1]
    finish = array[2]*60+array[3]

    sa = finish - now
    K = array[4]
    ans = 0
    for _ in range(int(1e15)):
        if now + K < finish:
            ans += 1
        else:
            break
        now += 1

    print(ans)


if __name__ == '__main__':
    main()
def main():
    H1, M1, H2, M2, K = map(int, input().split())

    t1 = 60*H1 + M1
    t2 = 60*H2 + M2

    d = 0
    if t1 <= t2:
        d = t2 - t1
    else:
        d = 60*24 - t1 + t2

    print(max(0, d - K))
    
if __name__ == "__main__":
    main()
h1, m1, h2, m2, k = map(int, input().split(' '))
print((h2 - h1) * 60 + m2 - m1 - k)
h1,m1,h2,m2,k = [int(hoge) for hoge in input().split()]
diff = h1*60 + m1 - h2*60 - m2
diff *= -1
print(max(0,diff-k))
h1, m1, h2, m2, k = map(int, input().split())
if h1 > h2:
	h2 += 24

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

if t - k <= 0:
	print(0)
else:
	print(t - k)
h1,m1,h2,m2,k=map(int,input().split())
d1=h1*60+m1
d2=h2*60+m2
if d1<=d2:
    d=d2-d1
else:
    d=24*60-d1+d2
print(d-k)