peterverebics/CodeNet_Python_118 huggingface dataset:
h1,m1,h2,m2,k = map(int,input().split())

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

print(a2-a1-k)
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
def Yes(x):print("Yes")if x==True else print("No")
h1,m1,h2,m2,k=NM()
x=h1*60+m1
y=h2*60+m2
if y>x:
    print(y-x-k)
else:
    print(y+60*24-x-k)
import datetime
h,m,eh,em,k = map(int,input().split())
start = h*60 + m
end = eh*60 + em
if end - start > k:
    print(end - k - start)
else:
    print(0)
H1, M1, H2, M2, K = list(map(int, input().split()))

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

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

H = H2 - H1
M = M2 - M1

print(max(0, H * 60 + M - K))
H1,M1,H2,M2,K=map(int, input().split())
time=(H2-H1)*60+(M2-M1)
print(time-K)
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())
d = h2 - h1
d *= 60
d += m2 - m1
print(max(d-k,0))
h1,m1,h2,m2,k=map(int,input().split())
s=h2*60+m2-k-(h1*60+m1)
print(s)
H1,M1,H2,M2,K=map(int,input().split())
print(((H2*60+M2)-(H1*60+M1))-K)
h_1 , m_1, h_2, m_2 , k = map(int, input().split())
# study_time = ((h_2*60 + m_2) - (h_1*60 + m_1))
study_time = ((h_2*60 + m_2) - (h_1*60 + m_1))
print(study_time - k)
h1,m1,h2,m2,k = map(int,input().split())

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

b = a[0]*60 + a[1]
c = a[2]*60 + a[3]

if c-b<a[4]:
    print(0)
else:
    print(c-b-a[4])
h,m,h2,m2,k = map(int,input().split())

a = h2 - h
b = m2 - m

minu = a * 60 + b

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

diff = (h2 - h1) * 60 + m2 - m1
print(max(diff - k, 0))
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H1, M1, H2, M2, K = map(int, rl().split())
    
    t1 = H1 * 60 + M1
    t2 = H2 * 60 + M2
    ans = t2 - K - t1
    print(ans)


if __name__ == '__main__':
    solve()
h1, m1, h2, m2, k = map(int, input().split())
oktime = h2*60+m2 - (h1*60+m1)
print(oktime-k)
H0,M0,H1,M1,K = map(int, input().split())
a = (H1*60+M1) - (H0*60+M0) - K
print(a)
# A
H1,M1,H2,M2,K = map(int,input().split())
if H2 >= H1:
    h = (H2-H1)*60 + M2- M1 - K
    print(h)
else:
    h = (24-H1+ H2)*60 + M2- M1 - K
    print(h)
H1,M1,H2,M2,K  = list(map(int, input().split()))

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


print(main())
#print('Yes' if main() else 'No')
#print('YES' if main() else 'NO')
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

h1,m1,h2,m2,k = mp()
hun1 = h1*60+m1
hun2 = h2*60+m2
print(hun2-hun1-k)
a,b,c,d,e=map(int,input().split())

x=((c*60+d)-(a*60+b))-e

if x<0:
    x=x+1440
print(x)
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H1, M1, H2, M2, K = ZZ()
    start = 60 * H1 + M1
    end = 60 * H2 + M2
    print(max(0, end - start - K))

    return

if __name__ == '__main__':
    main()
h1,m1,h2,m2,k = map(int,input().split())
t = (h2-h1-(m2<m1))*60+(m2-m1+60)%60
print(t-k)
H1,M1,H2,M2,K = map(int, input().split())
mm = M2 - M1
hh = H2 - H1
M = hh*60 + mm
print(M-K)
H1,M1,H2,M2,K = map(int, input().split()) 
sum1=H1*60+M1
sum2=H2*60+M2
hiku=sum2-sum1
if hiku-K<0:
    print("0")
else:
    print(hiku-K)
h1,m1,h2,m2,k=map(int,input().split())
ans=h2*60+m2-k-h1*60-m1
print(ans)
H_1, M_1, H_2, M_2, K = map(int, input().split())

H_ = H_2 * 60 + M_2 - K
H = H_ - (H_1*60+M_1)
print(H)
H1,M1,H2,M2,K=map(int,input().split())
time1=H1*60+M1
time2=H2*60+M2
print(time2-time1-K)
def main():
    H1, M1, H2, M2, K = [int(value) for value in input().split(" ")]

    # K(min)-> Time min
    H = K // 60
    M = K % 60
    
    
    NH = H2 - H
    NM = M2 - M
    if NM < 0:
        NH -= 1
        NM = 60 + NM
    if NM - M1 < 0:
        RM = (NH - H1-1)*60 + 60+(NM-M1)
    else:
        RM = (NH - H1)*60 + (NM-M1)

    if RM < 0:
        RM = 0
    print(RM)

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

HOUR = H2 - H1
MINUTE = M2 - M1

After_H = HOUR *60
After_M = After_H + MINUTE
Ans = After_M - K

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

t1 = H1 * 60 + M1
t2 = H2 * 60 + M2
print(max(0, t2 - t1 - K))
H1, M1,H2,M2,K= map(int,input().split())
a = H1*60
b = H2*60
result = b -a 
c = M2 - M1
d = result + c
result2 = d - K
print(result2)
h1, m1, h2, m2, k = map(int, input().split())
h = h2 - h1
if m2 >= m1:
    m = m2 - m1
else:
    m = m2 + 60 - m1
    h -= 1
ans = h * 60 + m - k
if ans <= 0 :
    ans = 0
print(ans)
h1, m1, h2, m2, K = (int(i) for i in input().split())  

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

print(max(0, t2 - K - t1))
H1, M1, H2, M2, K = (int(x) for x in input().split())
if H1 > H2: 
    H1 -= 24

before = H1 * 60 + M1
after = H2 * 60 + M2
after -= K

time = after - before
print(time)
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()
h1, m1, h2, m2, k = map(int, input().split())
time1 = h1 * 60 + m1
time2 = h2 * 60 + m2
print(max(time2 - k - time1, 0))
h1,m1,h2,m2,k = map(int,input().split())
ne = h2 * 60 + m2
oki = h1 * 60 + m1
print(ne - oki - k)
def main():
    H1, M1, H2, M2, K = map(int, input().split())
    ans = max((H2 * 60 + M2) - (H1 * 60 + M1) - K, 0)
    print(ans)


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

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

ans = s - e - k
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())
if h1 > h2:
    h2 +=24
h = h2 - h1
m = m2 - m1
if m < 0:
    m = m + 60
    h = h - 1
time = h*60 + m 
print(time - k)
H1, M1, H2, M2, K = map(int, input().split())
print(H2*60+M2-H1*60-M1-K)
import datetime

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

dt1 = datetime.datetime.strptime(str(h1) + ':' + str(m1) + ':00', '%H:%M:%S')
dt2 = datetime.datetime.strptime(str(h2) + ':' + str(m2) + ':00', '%H:%M:%S')

se = (dt2 - dt1).seconds
mi = se / 60 - k
print(str(int(mi)))
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())

a = 60 * H1 + M1
b = 60 * H2 + M2
ans = b - a

print(max(0, b - K - a))
h1,m1,h2,m2,lens = [int(x) for x in input().split()]
available = (h2 * 60 + m2) - (h1 * 60 + m1)
answer = available - lens if available > lens else 0
print(answer)
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H1, M1, H2, M2, K = getlist()
	X = H2 * 60 + M2 - (H1 * 60 + M1)
	print(X - K)

if __name__ == '__main__':
	main()
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    H1, M1, H2, M2, K = LI()

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

if __name__ == '__main__':
    resolve()
h1,m1,h2,m2,k=map(int,input().split())
res=h2*60+m2-h1*60-m1-k
print(res)
a,b,c,d,e = map(int, input().split())
val = (c-a)*60+(d-b)
print(val-e)
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

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

sm = h2*60 + m2
gm = h1*60 + m1
ans = sm - gm - k

print(ans)
H1, M1, H2, M2, K = map(int, input().split())
morning = H1 * 60 + M1
zzz = H2 * 60 + M2
if morning > zzz:
    zzz += 24 * 60
time = zzz - morning - K
print(time)
a, b, c, d, e = map(int, input().split())
t = (c - a) * 60 -(b - d)
if t <= e:
    print(0)
else:
    print(t- e)
h_1, m_1, h_2, m_2, k = map(int,input().split())
t_1 = 60 * h_1 + m_1
t_2 = 60 * h_2 + m_2
t = t_2 - t_1
print(t - k)
H1,M1,H2,M2,K=map(int, input().split())

m1=H1*60+M1
m2=H2*60+M2

ans = m2-m1-K

if ans>0:
  print(ans)
else:
  print(0)
x = list(map(int, input().split(" ")))
h1 = x[0]
m1 = x[1]
h2 = x[2]
m2 = x[3]
s = x[4]
h = (h2-h1)*60
m = m2-m1
print((h+m)-s)
H1,M1,H2,M2,K = map(int,input().split())
L = (H2-H1)*60+(M2-M1)
print(L-K)
h1, m1, h2, m2, k = map(int, input().split())
l = h2 * 60 + m2 - h1 * 60 - m1
print(max(0, l - k))
h1,m1,h2,m2,k = map(int,input().split())
oki = h2*60+m2 - h1*60-m1
if(oki < 0):
    oki = 60*24 - oki

print(oki - k)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    h1,m1,h2,m2,K = map(int, readline().split())

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

    ans = sleep - K - wakeup
    print(ans)


if __name__ == "__main__":
    main()
h1,m1,h2,m2,k = map(int,input().split())
t = h2*60+m2-h1*60-m1-k
print(t)
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())
ans = h2*60+m2 - (h1*60+m1)
ans = max(0,ans-K)
print (ans)
a,b,c,d,k=map(int,input().split())
use=a*60+b 
want=c*60+d 
print(want-use-k)
l=input().split()
h1=int(l[0])
m1=int(l[1])
h2=int(l[2])
m2=int(l[3])
k=int(l[4])
print(60*h2+m2-60*h1-m1-k)
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())

print((H2-H1)*60+M2-M1-K)
h1, m1, h2, m2, k = map(int, input().split())
l = (60 * h2 + m2) -(60 * h1 + m1)
ans = l - k
print(ans)
h1,m1,h2,m2,k = map(int,input().split())
h = h2-h1
m = m2-m1
print(h*60+m-k)
import sys
readline = sys.stdin.buffer.readline

h1, m1, h2, m2, k = map(int, readline().split())
print(60 * (h2 - h1) + m2 - m1 - k)
h_1,m_1,h_2,m_2,k=map(int,input().split())
h_1*=60
h_2*=60
hour1=h_1+m_1
hour2=h_2+m_2
hour=hour2-hour1-k
if hour<0:
    hour=0
print(hour)
import sys
input = sys.stdin.readline
RS = input
RI = lambda x=int: x(RS())
RA = lambda x=int: map(x, RS().split())
RSS = lambda: RS().split()


def solve():
    start = h1*60 + m1
    end = h2*60 + m2
    print(end- k - start)
    return



h1, m1, h2, m2, k = RA()
solve()
H1, M1, H2, M2, K = map(int, input().split())
print(max((H2 - H1) * 60 + M2 - M1 - K, 0))
a, b, c, d, k = map(int, input().split());

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

print(y-x-k);
# -*- coding: utf-8 -*-

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

print((c-a)*60+(d-b)-e)
h1, m1, h2, m2, k = map(int, input().split())
awake = h2*60 + m2 - h1*60 - m1
print(awake - k)
H1, M1, H2, M2, K = map(int, input().split())

wakeup = 60 * H1 + M1
gotobed = 60 * H2 + M2
 
wake = gotobed - wakeup
 
answer = wake - K
 
print(answer)
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

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

print((c-a)*60 + (d-b) - e)
a,b,c,d,e=map(int,input().split())
print(max(0,c*60+d-(a*60+b)-e))
import datetime

def main():
    H1, M1, H2, M2, K = map(int,input().split())
    start = H1 * 60 + M1
    end = H2 * 60 + M2
    
    ans = end - start - K
    print(ans)
    


if __name__ == "__main__":
    main()
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C,D,K = MAP()
    print(C*60+D-A*60-B-K)

    

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

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

if H1 > H2:
  hour = H2+(24-H1)
else:
  hour = H2-H1

if M1 > M2:
  hour -= 1
  minutes = M2+(60-M1)
else:
  minutes = M2-M1
print(hour*60+minutes-K)
h1,m1,h2,m2,k = map(int,input().split())
time = (h2*60 + m2) - (h1*60 + m1) -k
print(time)
h1, m1, h2, m2, k = map(int, input().split())

h1*=60
h1+=m1
h2*=60
h2+=m2
if h1 > h2:
  h2+=60*24

begin = h2 - k

print(begin-h1)
def main():
  h1,m1,h2,m2,k=map(int,input().split())
  a=60*(h2-h1)+(m2-m1)
  print(max(0,a-k))
if __name__=='__main__':
  main()
H1,M1,H2,M2,K=list(map(int,input().split()))
if M2<M1:
    M2+=60
    H2-=1
keika=60*(H2-H1)+M2-M1
print(keika-K)
h1, m1, h2, m2, k = map(int, input().split())

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

print(end - front-k)
h1, m1, h2, m2, k = map(int, input().split())
time = max((h2 * 60 + m2) - (h1 * 60 + m1) - k, 0)
print(time)
okiji,okihun,neji,nehun,benji=map(int,input().split())
print((neji*60+nehun)-(okiji*60+okihun)-benji)
h1,m1,h2,m2,k = map(int,input().split())
ans = 0
ans += (h2 - h1)*60 + (m2 - m1) - k

print(ans)
h1, m1, h2, m2, k = map(int, input().split())
rest = max((h2 - h1) * 60 + (m2 - m1) - k, 0)
print(rest)
a,b,c,d,e = map(int,input().split())
ans = (c-a) * 60
ans += d-b
print(ans-e)
h1,m1,h2,m2,k = map(int,input().split())
t = 60*(h2-h1)+(m2-m1)
print(t-k)
H1, M1, H2, M2, K= map(int,input().split())
ans=H2-H1
ans*=60
ans+=M2-M1
ans+= -K
if ans <0:
  ans=0
print(ans)
H1,M1,H2,M2,K = map(int,input().split())
S = H1*60+M1
F = H2*60+M2
ans = F-S-K
print(ans)
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

if b < d:
    m = (c-a)*60 + (d-b)
else:
    m = (c-a-1)*60 + (60 - (b-d))

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

st = h1 * 60 + m1
ed = h2 * 60 + m2
print(ed - st - k)
h1, m1, h2, m2, k = map(int, input().split())
hour = h2-h1
minute = m2 - m1
time = hour*60 + minute
ans = time - k
print(ans)
h1, m1, h2, m2, k = map(int, input().split())
a1 = h1 * 60 + m1
a2 = h2 * 60 + m2
print((a2 - a1) - k)
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

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

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

print(ans - k)
timer = list(map(int, input().split()))

start  = (timer[0]*60) + timer[1]
finish = (timer[2]*60) + timer[3]
study  = finish - start - timer[4]

print(study)
a, b, c, d, k = map(int, input().split())

h = c - a
m = d - b

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

ans = (H2-H1)*60+M2-M1-K
print(ans)
import datetime as dt

H1, M1, H2, M2, K = map(int, input().split())
start = dt.timedelta(hours=H1, minutes=M1)
end = dt.timedelta(hours=H2, minutes=M2)
# print((end - start).seconds // 60)
total = (end - start).seconds // 60
print(total - K)
h1, m1, h2, m2, k = map(int, input().split())
print((h2-h1)*60+(m2-m1)-k)
H1,M1,H2,M2,K = input().split(' ')

okiteru = int(H2)*60 + int(M2) - int(H1)*60 - int(M1)

kaisi = okiteru - int(K)

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

h = (H2 - H1) * 60
m = M2 - M1

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


if __name__ == "__main__":
    main()
line=input().split()
line=[int(i) for i in line]

wake=60*line[0]+line[1]
sleep=60*line[2]+line[3]
time=sleep-wake
start=time-line[4]
print(start)
i = list(map(int, input().split()))
H1 = i[0]
M1 = i[1]
H2 = i[2]
M2 = i[3]
studyM = i[4]

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

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

print((H2-H1-1)*60+(M2+(60-M1))-K)
def main():
    h1, m1, h2, m2, k = [int(v) for v in input().split()]
    t1 = 60 * h1 + m1
    t2 = 60 * h2 + m2

    ans = t2 - t1 - k
    print(int(ans))


if __name__ == '__main__':
    main()
import sys
readline = sys.stdin.buffer.readline
h1, m1, h2, m2, k = map(int, readline().split())
print(60 * (h2 - h1) + m2 - m1 - k)
fH, fM, sH, sM, K = map(int, input().split())

print(60 *(sH - fH) + sM -fM -K)
a, b, c, d, e = map(int, input().split())
total= (c-a)*60 +(d-b)-e
print(total)
import sys
import math
import itertools
h1, m1, h2, m2, k = map(int, input().split())
print(max((h2-h1)*60 + (m2-m1)-k,0))
i_l_s = input().split()
i_l = list(map(int, i_l_s))
 
hour = i_l[4]//60
min = i_l[4]%60
 
before = [i_l[0]+hour, i_l[1]+min]
after = [i_l[2], i_l[3]]
 
if(after[0]-before[0] ==0):
    print(after[1]-before[1])
else:
  result = after[1]-before[1] + 60*(after[0]-before[0])
  print(result)
h1, m1, h2, m2, k = map(int,input().split())

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

print(study_time)
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()))

s = (h1*60)+m1
e = (h2*60)+m2

print(e-s-k)
line = input()
h1, m1, h2, m2, k = line.split(" ")
h1, m1, h2, m2, k = int(h1), int(m1), int(h2), int(m2), int(k)

houre = h2 - h1
minute = m2 - m1

print(houre * 60 + minute - k)
h1, m1, h2, m2, K = list(map(int, input().split()))
if (h2 - h1)*60 + (m2-m1) < K:
    print('{}'.format(0))
else:
    print('{}'.format((h2 - h1)*60 + (m2-m1) - K))
h1, m1, h2, m2, k = map(int, input().split())
t = 0

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

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

if M >= m :
    k = (H - h) * 60
    k += M - m
    
else :
    k = (H - h - 1) * 60
    k += 60 - m
    k += M
    
if k - K <= 0 :
    print(0)
else :
    print(k - K)
a = input().split(" ")
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
a[3] = int(a[3])
a[4] = int(a[4])
f = (a[0] * 60) + a[1]
g = (a[2] * 60) + a[3]
l = g - f
print(l - a[4])
from datetime import datetime

H1,M1,H2,M2,K=[int(i) for i in input().split(" ")]

t1=datetime(2020,5,30,H1,M1,0)
t2=datetime(2020,5,30,H2,M2,0)
d=t2-t1
print(d.seconds//60-K)
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    H1, M1, H2, M2, K = [int(i) for i in input().strip().split()]
    return (H2*60 + M2) - (H1*60 + M1) - K


if __name__ == "__main__":
    print(main())
import sys
def main():
    H1, M1, H2, M2, K = map(int, input().split())
    
    h = H2 - H1 
    m = M2 - M1
    tot_minutes = h * 60 + m - K
    
    if tot_minutes <= 0:
        out = 0
    else:
        out = tot_minutes
    print(out)
main()
H1, M1, H2, M2, K = [int(i) for i in 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)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

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

print(t)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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())
a = h1*60+m1
b = h2*60+m2
print(b-a-k)
s = input().split()

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

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

t = t - k

print(t)
a, b, c, d, e = map(int, input().split())
# get a string
#s = raw_input()
# output
start = a*60+b
end = c*60+d
result = end - start - e
print(result)
from datetime import datetime, timedelta
h1, m1, h2, m2, k = [int(i) for i in input().split()]

t1 = datetime(year=1, month=1, day=1, hour=h1, minute=m1)
t2 = datetime(year=1, month=1, day=1, hour=h2, minute=m2)
if h2 > h1:
    print((t2-t1-timedelta(minutes=k)).seconds//60)
elif h1 == h2 and m2 > m1:
    print((t2-t1-timedelta(minutes=k)).seconds//60)
else:
    t2 = t2.replace(day=2)
    print((t2-t1-timedelta(minutes=k)).seconds//60)
h1, m1, h2, m2, k = map(int, input().split())

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

p = time - k

ans = time - p

print(p)
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    H1, M1, H2, M2, K = readnums()
    H2 -= 1
    M2 += 60
    print((H2 - H1) * 60 + (M2 - M1) - K)


if __name__ == "__main__":
    main()
h1, m1, h2, m2, k = map(int, input().split())
d = (h2 - h1) * 60 + (m2 - m1)
print(d - k)
H1,M1,H2,M2,K = map(int,input().split())
m1 = H1*60 + M1
m2 = H2*60 + M2
l = m2-K-m1
print(max(0,l))
a,b,c,d,e = map(int,input().split())
print((c*60+d)-(a*60+b)-e)
a,b,c,d,e = (int(a) for a in input().split())

h = c-a
m = d-b
if m < 0 :
    h = h-1
    m = 60 + m

print(h * 60 + m - e)
import sys

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

print((H2 - H1) * 60 + M2 - M1 - K)
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    H1, M1, H2, M2, K = map(int, input().split())
    HM1 = H1*60+M1
    HM2 = H2*60+M2
    print(HM2-HM1-K)

if __name__ == '__main__':
    main()
import math

if __name__ == '__main__':
    s = input().rstrip().split(' ')
    H1, M1, H2, M2, K = int(s[0]),int(s[1]),int(s[2]),int(s[3]),int(s[4])
    if (H1, M1) > (H2, M2):
        H2 += 24

    min1 = H1 * 60 + M1
    min2 = H2 * 60 + M2

    print(min2 - min1 - K)
H_1,M_1,H_2,M_2,K = map(int,input().split())
if H_2-H_1<0:
    print((H_2-H_1+24)*60+M_2-M_1-K)
else:
    print(H_2*60+M_2-H_1*60-M_1-K)
import sys

if __name__ == "__main__":
    h1, m1, h2, m2, k = map(int, input().split(" "))
    time_awake = (m2 - m1) + (h2 - h1) * 60 - k
    print(0 if time_awake < 0 else time_awake)
def difference(h1, m1, h2, m2, k): 
    t1 = h1 * 60 + m1 
    t2 = h2 * 60 + m2  
    diff = t2-t1
    print(diff - k)

L = input().split()
H1 = int(L[0])
M1 = int(L[1])
H2 = int(L[2])
M2 = int(L[3])
K = int(L[4])

difference(H1, M1, H2, M2, K)
H1, M1, H2, M2, K = map(int, input().split())
t = (H2 * 60 + M2) - (H1 * 60 + M1)
print(t - K)
H1,M1,H2,M2,K = [ int(x) for x in input().split()]

A1 = H1*60+M1
A2 = H2*60+M2

answer = A2 - A1 - K

print(answer)
h1, m1, h2, m2, k = map(int, input().split())
if m2-k < 0:
    m2 = 60+(m2-k)
    h2 -= 1
else :
    m2 -= k
minute1 = h1*60+m1
minute2 = h2*60+m2
print(minute2-minute1)
h1,m1,h2,m2,k=map(int,input().split())
ans=(h2-h1)*60+(m2-m1)-k
print(ans)
from math import *
from sys import stdin,stdout
input=stdin.buffer.readline

ip=[int(x) for x in input().split()]
h1=ip[0]
m1=ip[1]
h2=ip[2]
m2=ip[3]
k=ip[4]

time=(h2*60+m2)-(h1*60+m1)-k
print(time)
h1,m1,h2,m2,k = [int(i) for i in input().split()]
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2
print(t2 - t1 - k)
h1, m1, h2, m2, k = map(int, input().split())

h = h2-h1
m = m2-m1
m += h*60
print(m-k)
def study_time(h1, m1, h2, m2, k):
    result = (h2 - h1) * 60 + m2 - m1 - k
    return result

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

if __name__ == '__main__':
    print(study_time(h1, m1, h2, m2, k))
import datetime

#intの場合
H1,M1,H2,M2,K = map(int,input().split())

wakeup = datetime.datetime(2020,5,30,H1,M1,0)
sleep = datetime.datetime(2020,5,30,H2,M2,0)

active = sleep - wakeup
delta = int((active.seconds)/60)

ans = delta - K
print(ans)
h1, m1, h2, m2, k = map(int, input().split())
piyo = h2*60 + m2 - (h1*60 + m1)
result = max(piyo - k, 0)
print(result)
H1,M1,H2,M2,K=map(int,input().split())
if H1>H2:H2+=24
print((H2-H1)*60+M2-M1-K)
h1, m1, h2, m2, k = map(int, input().split())
t1, t2 = h1*60+m1, h2*60+m2
if t1 > t2:
    t2 += 60*24
ans = t2-t1-k
print(ans)