Problem:
 Score : 100 points    Problem Statement In this problem, we use the 24 -hour clock.  Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2 . (See Sample Inputs below for clarity.)
He has decided to study for K consecutive minutes while he is up.
What is the length of the period in which he can start studying?      Constraints  0 \le H_1, H_2 \le 23  0 \le M_1, M_2 \le 59  The time H_1 : M_1 comes before the time H_2 : M_2 .  K \ge 1  Takahashi is up for at least K minutes.  All values in input are integers (without leading zeros).         Input Input is given from Standard Input in the following format:  H_1  M_1  H_2  M_2  K       Output Print the length of the period in which he can start studying, as an integer.        Sample Input 1 10 0 15 0 30      Sample Output 1 270  Takahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.
It takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270 .       Sample Input 2 10 0 12 0 120      Sample Output 2 0  Takahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0 .

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

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

ans=length-K

print(ans)

Solution (Python):
H1, M1, H2, M2, K = map(int, input().split())
T = (H2 - H1) * 60 + (M2 - M1)
print(T - K)

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

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

Solution (Python):
def main() -> None:
    h1, m1, h2, m2, k = map(int, input().split())

    if h1 > h2:
        h2 += 24
    length = (h2*60+m2) - (h1*60+m1)
    print(max(0, length - k))

    return


if __name__ == '__main__':
    main()

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

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

Solution (Python):


import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


H1,M1,H2,M2,K = MI()
print(max(0,60*H2+M2-60*H1-M1-K))

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h1,m1,h2,m2,k=nii()
minute=(h2-h1)*60
minute+=m2-m1
minute-=k

print(minute)

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

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

Solution (Python):
h1, m1, h2, m2, K = map(int, input().split())

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

m -= K

print(m)

Solution (Python):
def main():
    H1,M1,H2,M2,K = map(int,input().split())
    time1 = H1*60 + M1
    time2 = H2*60 + M2
    time = time2-time1
    ans = time-K
    return ans

print(main())

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
H = h2 - h1
if m1 <= m2:
    M = m2 - m1
else:
    M = 60 - m1 + m2
    H -= 1
print(H*60 + M - k)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H1, M1, H2, M2, K = mapint()
if M2>=M1:
    minutes = (H2-H1)*60
    minutes += M2-M1
else:
    minutes = (H2-H1-1)*60
    minutes += M2-M1+60
print(max(0, minutes-K))

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h1,m1,h2,m2,k = inpl()
if m1 > m2:
    m2 += 60
    h2 -= 1
print((h2-h1)*60+(m2-m1)-k)

Solution (Python):
a,b,c,d,e=map(int,input().split())
x=a*60+b
y=c*60+d
print(y-x-e)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


H1,M1,H2,M2,K = MI()
print(max(0,60*H2+M2-60*H1-M1-K))

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

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

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

print(m - k)

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

if m1 <= m2:
    h = h2 - h1
    m = m2 - m1
else:
    h = h2 - h1 - 1
    m = m2 - m1 + 60

m += 60 * h

print(m - k)

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
x1 = h1 * 60 + m1
x2 = h2 * 60 + m2
print(x2 - x1 - k)

Solution (Python):
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()

Solution (Python):
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()

Solution (Python):

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

Solution (Python):
H_1, M_1, H_2, M_2, K = list(map(int, input().split(' ')))

print((H_2-H_1)*60+(M_2-M_1)-K)

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

print((H2-H1)*60+(M2-M1)-K if (M2-M1) >= 0 else (H2-H1)*60+(M2-M1)-K)

Solution (Python):
H1,M1,H2,M2,K = map (int, input ().split ())
S = H1*60+M1
G = H2*60+M2
p = G-S
if p-K < 0:
  print (0)
else:
  print (p-K)

Solution (Python):
h,m,hh,mm,k = map(int,input().split())
x = hh*60-h*60+mm-m
print(x-k)

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

Solution (Python):
H1,M1,H2,M2,K = map(int,input().split())
A1 = H1*60+M1
A2 = H2*60+M2
print(max(0,A2-A1-K))

Solution (Python):
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)

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

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

Solution (Python):
h1, m1, h2, m2, s = map(int, input().split())
m = 60 * (h2 - h1) + (m2 - m1)
print(m - s)

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

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split(' '))
print(60*(h2-h1)+m2-m1-k)

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

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

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

Solution (Python):
x,d,y,r,k=map(int,input().split())
s=x*60+d
ss=y*60+r
print(ss-s-k)

Solution (Python):
import datetime

lst = input().split()

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

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

print(int(d - k))

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

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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
time1 = h1 * 60 + m1
time2 = h2 * 60 + m2
print(max(time2 - k - time1, 0))

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
oktime = h2*60+m2 - (h1*60+m1)
print(oktime-k)

Solution (Python):
a = input().split()
print((int(a[2]) - int(a[0])) * 60 + (int(a[3]) - int(a[1])) - int(a[4]) )

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

Solution (Python):
h1,m1,h2,m2,K = map(int,input().split() )

H=h2-h1
M=m2-m1

if(M<0):
  M += 60
  H -= 1
if(H<0):
  H += 24

M += H*60

ans =M - K
print(ans)

Solution (Python):
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()

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

Solution (Python):
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)

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

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

print(data)

Solution (Python):
h1, m1, h2, m2, k = [int(i) for i in input().split()]

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

m = 0
if m1 == m2:
  m = 24 * 60
elif m1 < m2:
  m = m2 - m1
else:
  m = 24 * 60 - (m1 - m2)

print(m - k)

Solution (Python):

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

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

c = a+b

d = c-k
print(d)

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

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

print((h2 * 60 + m2) - (h1 * 60 + m1) - k)

Solution (Python):
h1,m1,h2,m2,k = map(int,input().split())
hour = (h2 - h1) * 60
minutes = m2 - m1
print(hour + minutes - k)

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
gap = h2 * 60 + m2 - h1 * 60 - m1
ans = gap - k
print(ans)

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

Solution (Python):
h, m, h2, m2, k = map(int, input().split())

g = h2 * 60 + m2
s = h * 60 + m

ans = g - k - s
print(ans)

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

Solution (Python):
H1,M1,H2,M2,K=map(int,input().split())
t1=H1*60+M1
t2=H2*60+M2
print(t2-K-t1)

Solution (Python):
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()

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

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

Solution (Python):
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])

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

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

Solution (Python):
sh,sm,eh,em,t=map(int,input().split())
print((eh-sh)*60+em-sm-t)

Solution (Python):
h1, m1, h2, m2, k = list(map(int, input().split()))
 
s = (h1*60)+m1
e = (h2*60)+m2
 
print(e-s-k)

Solution (Python):
H1, M1, H2, M2, K = map(int, input().split())
m1 = 60*H1 + M1
m2 = 60*H2 + M2
print(m2-m1-K)

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

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

print(e-s-k)

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

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

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
st = h1 * 60 + m1
ed = h2 * 60 + m2
ans = ed - st - k
if ans < 0:
    ans = 0
print(ans)

Solution (Python):
a,b,c,d,e=map(int,input().split())
f=60*c+d-60*a-b-e
print(f)

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

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

H1 *= 60
H2 *= 60

start = H1 + M1
end = H2 + M2

time = end - start
ans = time - K

print(ans)

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

Solution (Python):
a,b,c,d,k=map(int,input().split())
print((c-a)*60+(d-b)-k)

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
t = (h2 - h1) * 60 + (m2 - m1)
ans = t - k
print(ans)

Solution (Python):
a, b, c, d, e = [int(_) for _ in input().split()]
print(c * 60 + d - a * 60 - b - e)

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
length=(h2*60+m2)-(h1*60+m1)
print(length-k)

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

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

c = a+b

d = c-k
print(d)

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

if(M2 < M1):
    m = 60-(M1-M2)
    print((H2-H1-1)*60+m-K)
else:
    print((H2-H1)*60+(M2-M1)-K)

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

Solution (Python):
if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    print(a[2]*60 + a[3] -a[0]*60 - a[1] -a[4] )

Solution (Python):
import sys
def Ii():return int(sys.stdin.buffer.read())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

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

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

print((h2*60+m2)-(h1*60+m1)-k)

Solution (Python):
H1,M1,H2,M2,K = (int(x) for x in input().split())
print(H2*60+M2-H1*60-M1-K)

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

x = H1*60+M1
y = H2*60+M2

print(y-x-K)

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

Solution (Python):
h1, m1, h2, m2, k = [int(_) for _ in input().split()]

print((h2 - h1) * 60 + m2 - m1 - k)

Solution (Python):
ip = [int(s) for s in input().split(' ')]

h = ip[2] - ip[0]
m = ip[3] - ip[1]

total = (h * 60) + m - ip[4]

if total >= 0:
    print(str(total))
else:
    print(str(0))

Solution (Python):
H_1,M_1,H_2,M_2,K = map(int,input().split())
time_1 = H_1*60+M_1
time_2 = H_2*60+M_2
print(time_2-time_1-K)

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

Solution (Python):
def solve(h1, m1, h2, m2, k):
    return (h2-h1)*60 + (m2-m1) - k

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

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

Solution (Python):
a,b,c,d,k=map(int,input().split())
print((c-a)*60-b+d-k)

Solution (Python):
a,b,c,d,k=map(int,input().split())
print((c-a)*60-b+d-k)

Solution (Python):
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)

Solution (Python):
H1,M1,H2,M2,k = map(int,input().split())

h = ((H2-1)-H1)*60
m = (M2+60)-M1
print((h+m)-k)

Solution (Python):
H1,M1,H2,M2,K=map(int,input().split())
T1=H1*60+M1
T2=H2*60+M2
print(max(T2-T1-K,0))

Solution (Python):
input = list(map(int,input().split()))

h1 = input[0]
m1 = input[1]
h2 = input[2]
m2 = input[3]
k = input[4]

print(h2*60+m2-h1*60-m1-k)

Solution (Python):
a,b,c,d,e = map(int,input().split())
x = abs(a - c) * 60 - b + d - e
if x < 0:
    print(0)
else:
    print(x)

Solution (Python):
t = list(map(int, input().split()))
m = (t[2] - t[0]) * 60 + (t[3] - t[1])
print(m - t[4])

Solution (Python):
import sys

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

H, M, h, m, K = map(int, read().split())

m -= M
h -= H
if m < 0:
    m += 60
    h -= 1

answer = h * 60 + m - K
print(answer)

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    H1, M1, H2, M2, K = input_number_list()
    t1 = H1 * 60 + M1
    t2 = H2 * 60 + M2
    print(t2 - t1 - K)


if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d,e=map(int,input().split())
print(c*60+d-a*60-b-e)

Solution (Python):
a, b, c, d, K = map(int,input().split())
print(max(0,(60*c+d - 60*a-b)-K))

Solution (Python):
h = list(map(int, input().split()))

m = 0
m += 60 - h[1]
if m != 0: h[0] += 1
m += h[3] + (h[2]-h[0]) * 60
print(m-h[-1])

Solution (Python):
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

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

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

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

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,m,H,M,k=MI()
l=(M-m)+60*(H-h)
print(l-k)

Solution (Python):
H1,M1,H2,M2,K = map(int,input().split())
h1 = 60*H1+M1
h2 = 60*H2+M2
d = h2-h1
print(d-K)

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

time1 = h1*60 + m1
time2 = h2*60 + m2
print(max(0, time2-time1-k))

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
t = (h2-h1)*60 + m2-m1
ans = t-k
print(ans)

Solution (Python):
x1,y1,x2,y2,t=map(int,input().split())
print((x2-x1)*60+(y2-y1)-t)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

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

Solution (Python):
h1,h2,h3,h4,k = map(int,input().split())
h11 = h1 * 60 + h2
h22 = h3 * 60 + h4
print(h22-h11-k)

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

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
r=((h2-h1)*60)+m2-m1-k
if r>=0:
  print(r)
else:
  print(0)

Solution (Python):
h, m, h2, m2, k = map(int, input().split())
ans = (h2 * 60 + m2) - (h * 60 + m) - k
print(ans)

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

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

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

Solution (Python):
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)

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
a1 = 60*h1 + m1
a2 = 60*h2 + m2
duration = abs(a2-a1)
ans = duration-k
if ans > 0:
    print(ans)
else:
    print(0)

Solution (Python):
a,b,c,d,k=map(int,input().split())
print(60*c+d-60*a-b-k)

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
s=60*(h2-h1)+(m2-m1)-k
print(s)

Solution (Python):
h1, m1, h2, m2, K = list(map(int, input().split()))

diff = (h2-h1) * 60 + m2-m1
print(diff - K)

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

wake_time = H2 * 60 + M2 - (H1 * 60 + M1)
ans = wake_time - K

print(ans)

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

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

Solution (Python):
h1,m1,h2,m2,k = map(int,input().split())
s = (h2*60 + m2)-(h1*60 + m1)-k
print(s)

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
hm1=60*h1+m1
hm2=60*h2+m2
ans=hm2-hm1-k
print(ans)

Solution (Python):

"""NOMURA プログラミングコンテスト 2020: A - Study Scheduling
https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a
"""


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

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
A = list(map(int, input().split()))

print((A[2]*60+A[3])-(A[0]*60+A[1])-A[4])

Solution (Python):
H1, M1, H2, M2, K = map(int, input().split())
T1 = (H2*60+M2) - (H1*60+M1)
T2 = T1 - K
print(T2)

Solution (Python):
a,b,c,d,e = map(int,input().split())
z = (c-a)*60 + (d-b)- e
print(z)

Solution (Python):
H1, M1, H2, M2, K = map(int, input().split())
if H1 == H2:
    ans = M2 - M1
else:
    ans = (H2 - H1) * 60
    ans += M2 - M1
ans -= K
print(ans)

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

print((h2*60+m2) - (h1*60+m1) - k)

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

Solution (Python):
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)

Solution (Python):
def main():
    import sys
    input = lambda: sys.stdin.readline().rstrip()

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

    m = 60 - m1
    h1 += 1
    m += (h2 - h1)*60 + m2
    print(max(0, m - k))
main()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()

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

m = 60 - m1
h1 += 1
m += (h2 - h1)*60 + m2
print(max(0, m - k))

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

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

ans = h - k

print(ans)

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

Solution (Python):
a, b, c, d, k = map(int, input().split())
total = (c - a) * 60 + d - b
print(total - k)

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

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

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

ans = min2-min1-k
ans = max(0,ans)
print(ans)

Solution (Python):
a,b,c,d,e=map(int,input().split())
print(60*(c-a)+(d-b)-e)

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

Solution (Python):
import math

h1,m1,h2,m2,k=map(int,input().split())
start=60*h1+m1
end=60*h2+m2


print(end-start-k)
"""

a=[]
temp=input().split()
for i in range(n):
    a.append(int(temp[i])-1)

routetemp=[]
routetemp.append(0)
while True:
    if a[routetemp[-1]] in routetemp:
        roop=len(routetemp)-routetemp.index(a[routetemp[-1]])
        pre=routetemp.index(a[routetemp[-1]])
        break
    routetemp.append(a[routetemp[-1]])




num=(k-pre)%roop

print(routetemp[pre+num]+1)
"""

Solution (Python):
from sys import stdin
H1, M1, H2, M2, K = [int(_) for _ in stdin.readline().rstrip().split()]
print(((H2-H1)*60 + (M2-M1)) - K)

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

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

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

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

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

Solution (Python):
i = list(map(int, input().split()))
print((i[2]-i[0])*60+(i[3]-i[1])-i[4])

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

Solution (Python):
H1, M1, H2, M2, K = list(map(int, input().strip().split()))
ans = H2 * 60 + M2 - H1 * 60 - M1
if ans <= 0:
  ans += 24 * 60
print(ans - K)

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

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

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

Solution (Python):
H1,M1,H2,M2,K = map(int,input().split())
A = (H1 * 60) + M1
B = (H2 * 60) + M2
C = B - A
print(C-K)

Solution (Python):
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))
print(study_time - k)

Solution (Python):
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)

Solution (Python):

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

resolve()

Solution (Python):
S = list(map(int, input().split()))
A = S[0]*60 + S[1]
B = S[2]*60 + S[3]
print(B-A-S[4])

Solution (Python):
a=list(map(int, input().split(' ')))

h=a[2]-a[0]
m=a[3]-a[1]
mt=h*60+m

print(mt-a[4])

Solution (Python):
a = list(map(int, input().split()))
b = (a[2] * 60 + a[3]) - (a[0] * 60 + a[1])
print(b - a[4])

Solution (Python):
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()

Solution (Python):
string = input()
nums = string.split(' ')

hour = int(nums[2]) - int(nums[0])
minute = int(nums[3]) - int(nums[1])
time = hour * 60 + minute - int(nums[4])

print(time)

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

deltaH = h2 - h1
deltaM = m2 - m1
delta = deltaH * 60 + deltaM - k

print(delta)

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

difh = h2 - h1
difm = m2 - m1

t = 60 * difh + difm

print(max(0, t - k))

Solution (Python):
import sys
readline = sys.stdin.readline

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

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

Solution (Python):
a, b, c, d, K = map(int, input().split())

hour = (c-a) * 60
min = d - b
ans = hour + min - K
print(ans)

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

h_dif = h2 - h1
m_dif = m2 - m1

time = 60*h_dif + m_dif
print(time - k)

Solution (Python):
def calc_blank_minute(H1, M1, H2, M2, K):
  return (H2 * 60) + M2 - (H1 * 60) - M1 - K

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

Solution (Python):
import datetime
h1,m1,h2,m2,k = map(int,input().split())
end = datetime.datetime(2020,6,6,h2,m2)
start = datetime.datetime(2020,6,6,h1,m1)

sub = end-start-datetime.timedelta(minutes=k)
print(sub.seconds//60)

Solution (Python):
import math
import sys
readline = sys.stdin.readline


def main():
    h1, m1, h2, m2, k = map(int, readline().rstrip().split())
    print((max(0, (h2 - h1) * 60 + (m2 - m1) - k)))


if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    H1, M1, H2, M2, K = map(int, input().split())
    print((H2*60 + M2) - (H1*60 + M1) - K)

if __name__ == '__main__':
    solve()

Solution (Python):
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

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

ans= H2*60+M2 - (H1 * 60 + M1)
if(ans < 0):
    ans=ans+24*60

print(ans-K)

Solution (Python):
a,b,c,d,e=map(int,input().split())
x=(c-a)*60+(d-b)
print(x-e)

Solution (Python):
import math

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

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

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

getUpTime = H1 * 60 + M1
goToBed = H2 * 60 + M2

DisposableTime = goToBed - getUpTime
if K > DisposableTime:
    print(0)
else:
    print(DisposableTime - K)

Solution (Python):

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

h_m = (h2 - h1)*60
m = m2 - m1
tz = h_m + m

print(tz-k)

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

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

print(ans)

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

dh = h2 - h1
dm = m2 - m1

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

wm = dh*60 + dm
ans = wm - k

print(ans)

Solution (Python):
a,b,c,d,e=map(int,input().split())
x=a*60+b
y=c*60+d
y-=x
print(y-e)

Solution (Python):
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))

Solution (Python):
import math
h_one,m_one,h_two,m_two,k = map(int,input().split())

hour = h_two - (h_one + 1)
minute = (60 - m_one) + m_two

print(60*hour + minute - k)

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
if h1 > h2:
    h1 += 24

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

Solution (Python):
h1,m1,h2,m2,k = map(int,input().split())
d1 = h1 * 60 + m1
d2 = h2 * 60 + m2
print(d2 - d1 - k)

Solution (Python):



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

Solution (Python):
H1,M1,H2,M2,K = map(int,input().split())
start,end = 60*H1+M1,60*H2+M2
print(abs(start-end) - K) if end-K>0 else print(0)

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
awake = h2*60 + m2 - h1*60 - m1
print(awake - k)

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

Solution (Python):
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)

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

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

print((60*(h2-h1)+(m2-m1))-k)

Solution (Python):
h,m,hh,mm,k = map(int,input().split())
bi = h*60 + m
en = hh*60 +mm
print(max(en - bi - k,0))

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

Solution (Python):
H1, M1, H2, M2, K = map(int, input().split())
ans = H2*60 + M2 - H1*60 - M1 - K
print(ans)

Solution (Python):
h1,m1,h2,m2,k = map(int,input().split())
okiteiru = (h2*60+m2)-(h1*60+m1)
print(okiteiru - k)

Solution (Python):
a = list(map(int, input().split()))
kishou = a[0] * 60 + a[1]
shuusin = a[2] * 60 + a[3]
print(shuusin - kishou - a[4])

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

M_all = (H2 *60 + M2) - (H1 *60 + M1) - K

if M_all <= 0:
    print('0')
else:
    print(M_all)