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



import sys
import datetime

def input():
    return sys.stdin.readline()


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

    dt1 = datetime.datetime(2020, 5, 30, h1, m1)
    dt2 = datetime.datetime(2020, 5, 30, h2, m2)

    mean_t = dt2 - dt1

    k_second = k * 60

    ans_second = mean_t.seconds - k_second

    if ans_second <= 0:
        print(0)
    else:
        print(int(ans_second / 60))

if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
import sys
import math


input = sys.stdin.readline
 

def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))



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

h=h2-h1
m=m2-m1

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

ans=h*60+m-k

print(ans)

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

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

hour1 = (H1 * 60) + M1
hour2 = (H2 * 60) + M2
hour = hour2 - hour1
minute = hour - K
print(minute)

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

Solution (Python):

def main():
    H1,M1,H2,M2,K = list(map(int, input().split()))
    from datetime import datetime, timedelta
    time1 = datetime(2019,1,1,H1,M1,0)
    time2 = datetime(2019,1,1,H2,M2,0)
    kmin = timedelta(minutes=K)

    ans = (time2 - kmin) - time1

    print(ans.seconds//60)



if __name__ == '__main__':
    main()

Solution (Python):
H_1, M_1, H_2, M_2, K = map(int,input().split())
bef = H_1 * 60 + M_1
aft = H_2 * 60 + M_2
min = aft - bef
if min >  K:
    print(min - K)
else:
    print(0)

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

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

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

Solution (Python):

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

dt1=datetime.datetime(year=1,month=1,day=1,hour=H1,minute=M1)
dt2=datetime.datetime(year=1,month=1,day=1,hour=H2,minute=M2)

dt_diff=dt2-dt1

def timedelta_to_HM(td):
    sec = td.total_seconds()
    return (sec//60)

time=timedelta_to_HM(dt_diff)

A=time-K
A=int(A)

print(A)

Solution (Python):
Ha,Ma,Hb,Mb,K = list(map(int,input().split()))

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

print(tmp-K)

Solution (Python):
import datetime

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

    start = H1*60 + M1
    sleep = H2*60 + M2

    print(abs(sleep - start - K))


if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
a = input().split()
b = len(a)
c = int(a[0])
d = int(a[1])
e = int(a[2])
f = int(a[3])
g = int(a[4])

if g >= 60:
    h = g//60
    i = g%60
    if f>=i:
        A = e-h
        B = f-i
    else:
        A = e-h-1
        B = 60-(i-f)
else:
    if g<=f:
        A = e
        B = f-g
    else:
        A = e-1
        B = 60-(g-f)
if B>=d:
    C = A-c
    D = B-d
else:
    C = A-c-1
    D = 60-(d-B)
E = C*60
F = E+D
print(F)

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

startTime = (H1*60)+M1
endTime = (H2*60)+M2
time = endTime - startTime
posTime = time - K
if (posTime < 0):
  print(0)
else:
  print(posTime)

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

h1 = H1 * 60
m1 = M1
h2 = H2 * 60
m2 = M2

ans = (h2 + m2) - (h1 + m1) - K if (h2 + m2) > (h1 + m1) else (h2 + m2) - (h1 + m1) - K + 24 * 60

print(ans)

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

Solution (Python):
import datetime
h1,m1,h2,m2,k = map(int,input().split(' '))
dt1 = datetime.datetime(year=2020, month=5, day=30, hour=h1,minute=m1)
dt2 = datetime.datetime(year=2020, month=5, day=30, hour=h2,minute=m2)
dt3 = int((dt2-dt1).seconds/60-k)
print(dt3 if dt3 >=0 else 0)

Solution (Python):
inputs = input()

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

elapsedHour = H2 - H1
elapsedMin = M2 - M1

maxStudyStartTimeLength = elapsedHour * 60 + elapsedMin - K

print(maxStudyStartTimeLength)

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

Solution (Python):

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)

Solution (Python):
str = input()
arr = str.split(" ")
h_st = int(arr[0])
m_st = int(arr[1])
h_ed = int(arr[2])
m_ed = int(arr[3])
k = int(arr[4])
time_st = (h_st * 60)+m_st
time_ed = (h_ed * 60)+m_ed
result = time_ed - time_st - k
if result >= 0:
	print(result)
else:
    print("0")

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

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

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

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b,c,d,k = imap()

ans = (c-a)*60 + (d-b) - k
print(ans)

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

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

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

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

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

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

print(T2 - T1 - K)

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

Solution (Python):
mylist=list(map(int, input().split()))
H1=mylist[0]
M1=mylist[1]
H2=mylist[2]
M2=mylist[3]
K=mylist[4]
time=60*H2+M2-60*H1-M1
ptime=time-K
print(ptime)

Solution (Python):
hmk = input('')

h1 = int(hmk.split(' ')[0])
m1 = int(hmk.split(' ')[1])
h2 = int(hmk.split(' ')[2])
m2 = int(hmk.split(' ')[3])
k = int(hmk.split(' ')[4])

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

if min1 > min2:
    min2+=60*24

a = min2 - min1 - k
print(a)

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

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

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

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

Solution (Python):


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

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

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


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

if k > h*60 + m:
    print(0)
else:
    print(h*60 + m - k)

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

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

print(str(end - start - k))

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

Solution (Python):
H1, M1, H2, M2, K = [int(x) for x in input().split()]

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

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



start = a*60+b
end = c*60+d
result = end - start - e
print(result)

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

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

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

ans = time2 - k - time1
print(ans)

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



start = a*60+b
end = c*60+d
result = end - start - e
print(result)

Solution (Python):
import sys

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

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

Solution (Python):
from math import cos, pi

value = input().split()
for i in range(len(value)):
    value[i] = int(value[i])

if 0 <= value[0] <= 23 and 0 <= value[2] <= 23 and 0 <= value[1] <= 59 and 0 <= value[3] <= 59 and value[4] >= 1:
    W = (value[2] - value[0])*60 + value[3] - value[1] - value[4]
    print(W)
else:
    print("you enter value not in the valid range")

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

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

Solution (Python):
H1, M1, H2, M2, K = map(int, input().split())
dH = H2 - H1
dH_ = dH * 60
dM = M2 - M1
d = dH_ + dM
ans = d - 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())

def hourToMinute(H,M):
  ret = H*60 +M  
  return ret

start = hourToMinute(H1,M1)
fin = hourToMinute(H2,M2)

ans = fin - K

ans = ans- start

print(ans)

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

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

print(y)

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

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

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

Solution (Python):
(hs,ms,he,me,k) =map(int,input().split())
hour = (he - hs)*60
minute = me - ms - k
print(hour +minute)

Solution (Python):
import sys
a = []
for l in sys.stdin:
    a.append(l)
h1, m1, h2, m2, k  = a[0].split()
H1, M1, H2, M2, K = int(h1), int(m1), int(h2), int(m2), int(k)
time = 60 * H2 + M2 - (60*H1 + M1) - K
print(time)

Solution (Python):


from datetime import timedelta
import datetime

s_h, s_m, e_h, e_m, k = map(int, input().split())

start = datetime.datetime.combine(datetime.date.today(), datetime.time(s_h, s_m))
end = datetime.datetime.combine(datetime.date.today(), datetime.time(e_h, e_m))

total = end - start

study = timedelta(minutes = k)

print(int((total - study).seconds / 60))

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

h3, m3 = divmod(k, 60)

dh = h2 - h3
dm = m2 - m3
if dm < 0:
    dh -= 1
    dm = 60 + dm



ah = dh - h1
am = dm - m1
if am < 0:
    ah -= 1
    am = 60 + am

ans = ah * 60 + am
print(ans)

Solution (Python):
def main():
    h1,m1,h2,m2,k = map(int, input().split())
    a = (60*h1+m1)
    b = (60*h2+m2)
    if (b-a)<k:
        print(0)
    else:
        print((b-k)-a)

main()

Solution (Python):
a = input().split()
H1 = int(a[0])
M1 = int(a[1])
H2 = int(a[2])
M2 = int(a[3])
K = int(a[4])
time = (H2 * 60 + M2) - K
okiru = 60 * H1 + M1
print(time - okiru)

Solution (Python):


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

a=num_list[2]-num_list[0]
b=num_list[3]-num_list[1]
if b<0:
    a=a-1
    b=b+60
a=a*60
c=b+a-num_list[4]
if c<0:
    c=0
print(c)

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

h=(c-a)*60
h=h+(d-b)

h=h-e

print(h)

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

wake = H1 * 60 + M1
sleep = H2 * 60 + M2 - K
ans = 0
if wake <= sleep:
    ans = sleep - wake
else:
    time = 24 * 60
    ans = time - wake + sleep

print(ans)

Solution (Python):
h1,m1,h2,m2,k= list(map(int,input().split()))
t2 = h2*60+m2
t1 = h1*60+m1
owari = t2 - k
benkyou = owari - t1
if benkyou ==0 :
    print("0")
else:
    print(benkyou)

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

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

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

rest = minutes2 - minutes1
print(rest-k)

Solution (Python):
w_h, w_m, s_h, s_m,t = map(int,input().split())
s_t = s_h*60 + s_m -t
ans = s_t - w_h*60 - w_m
print(ans)

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

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

print(d - k)

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

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

def main():
    time = (60*H2 + M2) - (60*H1 + M1) - K
    print(time)
        
    
if __name__ == "__main__":
    main()

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

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

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

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

start = n[0]*60 + n[1]
end = n[2]*60 + n[3]

zikan = (end - start) - n[4]
print(zikan)

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

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

Solution (Python):
H_1,M_1,H_2,M_2,K=input().split()
H_1=int(H_1)
M_1=int(M_1)
H_2=int(H_2)
M_2=int(M_2)
K=int(K)
H1=H_1*60+M_1
H2=H_2*60+M_2
answer=H2-H1-K
print(answer)

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

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

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

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

if time>=e:
  print(time-e)
else:
  print(0)

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

Solution (Python):
h_1,m_1,h_2,m_2,k=map(int,input().split())
if h_1>h_2 and m_1>m_2:
  a=((h_2+12)-h_1)*60
  a=a-60
  b=60-(m_1-m_2)
elif h_1<h_2 and m_1>m_2:
  a=(h_2-h_1)*60
  a=a-60
  b=60-(m_1-m_2)

elif h_1>h_2 and m_1<m_2:
  a=((h_2+12)-h_1)*60
  b=m_2-m_1
else :
  a=(h_2-h_1)*60
  b=m_2-m_1
culc=b+a
result=culc-k

print(result)

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

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

Solution (Python):
h,m,h2,m2,k=map(int,input().split())
a=h*60+m
b=h2*60+m2
if a>b:
    b+=60*24


print(((b-a)-k))

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

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

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






import datetime

def get_waking_time(H,I,J,K):
    d1 = datetime.datetime(year=2020, month=5, day=30, hour=H, minute=I, microsecond=0)
    d2 = datetime.datetime(year=2020, month=5, day=30, hour=J, minute=K, microsecond=0)
    delta = d2 -d1
    return delta.seconds/60


print(int(get_waking_time(H1,M1,H2,M2)-K))

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

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

Solution (Python):
import datetime

H_1, M_1, H_2, M_2, K = map(int, input().split())

end_time = datetime.time(H_2, M_2, 00)

limit_time = datetime.datetime.combine(datetime.date(year=2017, month=10, day=10), end_time) - datetime.timedelta(minutes=K)

start_time = datetime.time(H_1, M_1, 00)

dif = limit_time - datetime.datetime.combine(datetime.date(year=2017, month=10, day=10), start_time)

print(dif.seconds//60)

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

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

time = at - bt

print(time-k)

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

Solution (Python):
import datetime

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

GetUpTime=datetime.datetime(2020, 5, 30, H1, M1)
GoToBedTime=datetime.datetime(2020, 5, 30, H2, M2)

DayTime=GoToBedTime-GetUpTime

TimeRange = int(DayTime.seconds)/60 - K
print(int(TimeRange))

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

Solution (Python):
import datetime

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

starttime = 60 * h1 + m1
endtime = 60 * h2 + m2 -k

td = endtime - starttime
if td <= 0:
    td = 0
print(td)

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

Solution (Python):
import datetime
year=2000
month=10
day=10
h1,m1,h2,m2,K = map(int,input().split())

dt1 = datetime.datetime(year=year,month=month,day=day,hour=h1,minute=m1)
dt2 = datetime.datetime(year=year,month=month,day=day,hour=h2,minute=m2)
dt2_bef = dt2 - datetime.timedelta(minutes=K)

td = dt1 - dt2_bef

if td.days<0:
    td = dt2_bef - dt1
print(int(td.total_seconds()//60))

Solution (Python):
x = list(map(int, input().split()))
h = (x[2] - x[0])*60
m = x[3] - x[1]
if m < 0:
    h -= 60
    m = 60 - x[1] + x[3]
ans = max(m+h-x[-1], 0)
print(ans)

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

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

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

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







d1 = datetime.datetime(year=2020, month=5, day=30, hour=H1, minute=M1)
d2 = datetime.datetime(year=2020, month=5, day=30, hour=H2, minute=M2)



min = d2 - d1




print(min.seconds // 60 - K)

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

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

Solution (Python):

def main():
    H1, M1, H2, M2, K = [int(value) for value in input().split(" ")]

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

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

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

Solution (Python):
import datetime


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)

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

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

if h1==h2:
  print(m2- m1 -k)
else:
  t += 60-m1
  t +=(h2- h1-1)*60
  t += m2
  print(t-k)

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

h1, m1, h2, m2, k = nm()
wu = h1*60 + m1
gb = h2*60 + m2
print(gb - wu - k)

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

hour = e // 60
min = e % 60

a += hour
b += min

if b >= 60:
    a += b // 60
    b %= 60

ans = 0
if b > d:
    c -= 1
    ans += 60 - (b - d)
else:
    ans += (d - b)

if c >= a:
    ans += 60 * (c - a)
else:
    print(0)
    exit()

print(ans)

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

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

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

print(time)

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

Solution (Python):
import datetime

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

a = datetime.datetime(2020, 5, 30, H2, M2)
b = datetime.datetime(2020, 5, 30, H1, M1)
delta = a - b
minute = delta.seconds // 60
print(minute - K)

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10


    h1,m1,h2,m2,k = LMIIS()
    wake = h1*60+m1
    sleep = h2*60+m2
    if wake > sleep:
        sleep += 24*60
    print((sleep-wake-k)%(24*60))

    
main()

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

time_time = (H2 - (H1 + 1)) * 60
time_minitue = (60- M1) + M2

cost_time =   (time_time + time_minitue) - K

print(cost_time)

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

Solution (Python):
import datetime

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

dt1 = datetime.datetime(year=2017, month=10, day=10, hour=h1, minute=m1)
dt2 = datetime.datetime(year=2017, month=10, day=10, hour=h2, minute=m2)

t = abs(dt2 - dt1)
print((t.seconds - k*60) // 60)

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

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

print(tmp)

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

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

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

if (wake > k):
    ans = wake - k
else:
    ans = 0

print(ans)

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

Solution (Python):
H1, M1, H2, M2, K = list(map(int, input().split()))
if M1 <= M2:
  all_time = (H2 - H1) * 60 + (M2 - M1)
else:
  all_time = (H2 - H1 - 1) * 60 + (60 + M2 - M1)

available_time = all_time - K
print(available_time)

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

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

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

Solution (Python):

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

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

if s < 0:
    s = 0

print(s)

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

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
h_time = h2 - h1
if m1 > m2:
    h_time -= 1
    m_time = 60 - m1 + m2
else:
    m_time = m2 - m1

study_time = (h_time * 60 + m_time) - k
if study_time <= 0:
    print(0)
else:
    print(study_time)

Solution (Python):
if __name__ == "__main__":
    h1, m1, h2, m2, k = map(int, input().split())
    wake = h1*60+m1
    sleep = h2*60+m2
    print(sleep-wake-k)

Solution (Python):
h_1,m_1,h_2,m_2,k=map(int,input().split())
print(60*(h_2-h_1)+m_2-m_1-k)

Solution (Python):
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())
print(h2 * 60 + m2 - h1 * 60 - m1 - k)

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

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

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

Solution (Python):
z=list(map(int,input().split(" ")))
h1=z[0]
t1=z[1]
h2=z[2]
t2=z[3]
m=z[4]
p=h1*60+t1
q=h2*60+t2
print(q-p-m)

Solution (Python):
h,m,e_h,e_m,k = list(map(int,input().split()))
h = h*60
e_h = e_h*60

print((e_h+e_m)-(h+m)-k)

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

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

    hm1 = H1 * 60 + M1
    hm2 = H2 * 60 + M2

    if hm1 > hm2:
        hm2 += 24 * 60
    diff = hm2 - hm1


    print(diff -K)


if __name__ == "__main__":
    resolve()

Solution (Python):
HMK=list(map(int,input().split()))
T=(HMK[2]*60+HMK[3])-(HMK[0]*60+HMK[1])
print(T-HMK[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=map(int,input().split())
print(h2*60+m2-h1*60-m1-k)

Solution (Python):
from sys import stdin, stdout  
  
def main(): 
	
	
	h1, m1, h2, m2, k  = [int(x) for x in stdin.readline().split()]
	
	totalMin = (((h2 - h1) * 60 ) - m1) + m2
	ans = totalMin - k
	stdout.write(str(ans)+'\n')

if __name__ == "__main__": 
	main()

Solution (Python):
h,m,H,M,k = map(int,input().split())
v = H*60+M
u = h*60+m+k
print(v-u)

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

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

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

print(res - k)

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

h = h2 - h1

if m2 >= m1:
    m = m2 - m1
else:
    m = 60 - (m1 - m2)
    h -= 1

working_time = h*60 + m

print(working_time - k)

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

Solution (Python):
import sys
from io import StringIO
import unittest


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

    if ans <= 0:
        print(0)
    else:
        print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10 0 15 0 30"""
        output = """270"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 0 12 0 120"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

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

ans = (h2 - h1)*60 + (m2-m1)
if (ans - k)>=0:
    print(ans - k)
else:
    print(0)