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 os
import sys
from io import BytesIO, IOBase
def main():
    h1,m1,h2,m2,k=map(int,input().split())
    ht=h2-h1
    ht*=60
    if(m2>=m1):
        ht+=m2-m1
    else:
        ht+=(m2-m1)
    print(ht-k)



BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()

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

if m1+mk >=60:
    h1 += 1
    m1 = m1 + mk -60
else:
    m1 = m1 + mk
h1 += hk

if m2- m1< 0:
    h2 -= 1
    m2 = m2- m1+ 60
else:
    m2 = m2 -m1
h = h2 - h1
print(h*60 + m2)

Solution (Python):
H1, M1, H2, M2, K = [int(n) for n in input().split()]
H = (H2-H1)*60
if M1<=M2:
    M = (M2-M1)
else:
    H -= 60
    M = M2+60-M1
print((H+M)-K)

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

h = int(h1) - int(h2)
m = 0
if int(m1) >= int(m2):
    m = int(m1) - int(m2)
else:
    h = h -1
    m = 60 + int(m1) - int(m2)
    
t = abs(h * 60 + m) - int(k)

print(t)

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

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

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

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

main = (data[2] - data[0]) * 60 + data[3] - data[1] - data[4]

print(main)

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

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

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

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

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





h3=0
m3=0
m3=m2-m1
h3=h2-h1




print(h3*60+m3-k)

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

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

H = (H2 - H1) * 60
M = M2 - M1

res = (H+M)

if res >= K:
    print(res - K)
else:
    print(0)

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

Solution (Python):
time = map(int, input().split())
list1=[]
for i in time:
    list1.append(i)
time1 = (list1[2]*60+list1[3])-(list1[0]*60+list1[1])
minute = time1  - list1[4]
print(minute)

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

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

Solution (Python):

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

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

Solution (Python):
h, m, H, M, K = list(map(int,input().split()))
if H >= h:  
  print(60*(H-h)+(M-m)-K)
else:
  print(60*(H-h+24)+(M-m)-K)

Solution (Python):
FH, FM, TH, TM, K = map(int, input().split())
M = (TH*60+TM)-(FH*60+FM)
print(M-K)

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

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

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

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

H1 = H1 * 60
H2 = H2 * 60

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

Solution (Python):
a,b,c,d,e = map(int,input().split())
A = a*60 + b
B = c*60 + d
X = B -A 
if X>e:
    print(X-e)
else:
    print(0)

Solution (Python):
H_1, M_1, H_2, M_2, K = 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())

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

hm=h*60
ans=hm+m

print(ans-k)

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

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

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

if b>d:
    h = c-a-1
    m = d+60-b
    print(h*60+m-e)
else:
    h = c-a
    m = d-b
    print(h*60+m-e)

Solution (Python):
import datetime

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

wake_up = datetime.timedelta(hours=h1, minutes=m1)
go_to_bed = datetime.timedelta(hours=h2, minutes=m2)
study_time = datetime.timedelta(minutes=k)

ans = (go_to_bed - study_time) - wake_up
print(ans.seconds // 60)

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 - k - h1 * 60 - m1))

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

if(0<=r):
  print(r)
else:
  print("0")

Solution (Python):


h1, m1, h2, m2, k = (int(x) for x in input().split())

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

print(end - start - k)

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

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

if H1 > H2 or (H1 == H2 and M1 >= M2):
    H2 += 24
    
diff_min = H2*60 + M2 - (H1*60 + M1)
if diff_min - K < 0:
    print(0)
else:
    print(diff_min - K)

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

if h1 < h2:
    t = (h2-h1-1)*60 + (60-m1) + m2
elif h1 == h2:
    t = m2 - m1
else:
    t = (60-m1) + (24 - h1 + h2)*60 + m2

print(t-k)

Solution (Python):

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


import datetime
h1 = h1.zfill(2)
h2 = h2.zfill(2)
m1 = m1.zfill(2)
m2 = m2.zfill(2)

o1 = h1+":"+m1+":00"
o2 = h2+":"+m2+":00"

dt1 = datetime.datetime.strptime(o1, '%H:%M:%S')
input_time1 = dt1.time()
dt2 = datetime.datetime.strptime(o2, '%H:%M:%S')
input_time2 = dt2.time()

total =int((dt2-dt1).total_seconds())/60

ans = int(total-int(k))
if ans >=0:
    print(ans)
else:
    print(0)

Solution (Python):
if __name__ == "__main__":
    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().split())

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

print(end-start-k)

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

ans = rem - K
print(ans)

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

time = (H_2*60 + M_2) - (H_1*60 + M_1)
ans = time - K

print(ans)

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

Solution (Python):
a,b,c,d,k = map(int,input().split())
h = c-a
mn = d-b

time = h*60+mn
ans = time-k
print(ans)

Solution (Python):

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



time = h2*60+m2 - (h1*60+m1)
print(time-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):

"""AtCoder nomura 2020: A - Study Scheduling - 
https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'

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):
a,b,c,d,k=map(int,input().split())
time=60*(c-a)+d-b
ans=time-k
print(ans)

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

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

ans = kisho-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):
t = [list(map(int, s.split())) for s in open(0)][0]
print((t[2]*60 + t[3]) - (t[0]*60 + t[1]) - t[4])

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

h=int(H2)-int(H1)
study=h*60+(int(M2)-int(M1))-int(K)

print(study)

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

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

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

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

Solution (Python):
h1, n1, h2, n2, k = map(int,input().split())
h = h2-h1
n = n2-n1
wake = 60*h + n
ans = wake-k
print(ans)

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

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

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

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

if M2>K:
  M2 = M2 - K
else:
  K = K - M2
  M2 = 0
  H2 = H2 - K//60 - 1
  K = K - (K//60) * 60
  M2 = 60 - K

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

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

ans = 0
HM1 = H1 * 60 + M1
HM2 = H2 * 60 + M2

ans = HM2 - HM1 - K

if ans >= 0:
    print(ans)
else:
    print("0")

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

hour = (H2-H1)*60
mini = M2-M1
sum = hour + mini

ans = sum-K

print(ans)

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

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

Solution (Python):
import sys



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

Solution (Python):

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

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

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

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

Solution (Python):

nums = list(map(int, input().split()))
H = nums[0]
M = nums[1]
h = nums[2]
m = nums[3]
k = nums[4]


wake = H * 60 + M

bed = h * 60 + m

available = bed - wake

print(available - k)

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

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

print(max(time-k, 0))

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())
time = 60 * (h2- h1) + m2 -m1
ans = time - k
if ans >= 0:
    print(ans)
else:
    print(0)

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

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

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

wake = get_minites(h1,m1)
sleep = get_minites(h2,m2)
ans = sleep - k - wake
print(ans)

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

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

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

J = H2 - H1
if (M1 > M2):
  J -= 1
  F = 60 + M2 - M1
else:
  F = M2 - M1

F = J * 60 + F

print(F - K)

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

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)

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

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

print(t)

Solution (Python):
h1,m1,h2,m2,x = map(int, input().split(" "))
start = h1*60+m1
end = h2*60+m2
ans = end-start -x
if ans <= 0 :
  print(0)
else:
  print(ans)

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

h1, m1, h2, m2, t = map(int, input().split())
if h1 < h2:
	diff = (h2 - h1 - 1) * 60 + (60 - m1) + m2
else:
	diff = m2 - m1
print(max(diff - t, 0))

Solution (Python):
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
 
YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()


show_flg=False
show_flg=True
ans=0


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

x=h2*60+m2-h1*60-m1
ans=x-k

print(ans)

Solution (Python):
import datetime
H1, M1, H2, M2, K = map(int, input().split())
t1 = datetime.datetime(2020, 1, 1, H1, M1)
t2 = datetime.datetime(2020, 1, 1, H2, M2)
print(int((t2 - t1).total_seconds() / 60 - K))

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

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

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

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

print(min2-min1-k)

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

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

ans = 0
if sl < su:
    ans = su + 1440 - sl
else:
    ans = sl - su

if ans < 0:
    print(0)
else:
    print(max(ans - k, 0))

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



x-=e
print(x)

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

H = h2-h1

if(m2-m1<0):
    M = 60 + m2 -m1
    H -=1
else:
    M = m2-m1

time = 60*H+M

if time <= k:
    print(0)
else:
    print(time-k)

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

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

p = time - k

ans = time - p

print(p)

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

if __name__ == '__main__':
	main()

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
j=0
if h2>=h1 and m2>=m1:
    j=60*(h2-h1)+m2-m1
elif h2>=h1 and m1>m2:
    j=60*(h2-h1-1)+(60-(m1-m2))
elif h2<h1 and m2>=m1:
    j=60*(24-(h1-h2))+m2-m1
else:
    j=60*(24-(h1-h2)-1)+(60-(m1-m2))
print(j-k)

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

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

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

total = (end - start).seconds // 60
print(total - K)

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

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

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

print(t)

Solution (Python):
H,M,HH,MM,K=map(int,input().split())

hour = HH - H -1
minute=60+MM-M
time = hour * 60 + minute - K

print(time)

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

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

if __name__ == "__main__":
    main()

Solution (Python):

"""this is python work script"""

def solver(H1, M1, H2, M2, K):
    """solve this problem"""
    min1 = H1 * 60 + M1
    min2 = H2 * 60 + M2
    diff = min2 - min1
    answer = diff - K
    return answer

def main():
    """main function"""
    H1, M1, H2, M2, K = list(map(int, input().rstrip().split(' ')))
    answer = solver(H1, M1, H2, M2, K)
    print(answer)

if __name__ == '__main__':
    main()

Solution (Python):
h, m, h2, m2, k = map(int,input().split())
remainh=h2-h
remainm=m2-m
if remainm<0:
    remainh-=1
    remainm+=60
print(remainh*60+remainm-k)

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    h1, m1, h2, m2, k = MI()

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

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


if __name__ == '__main__':
    solve()

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

if h1==h2:
    time = m2-m1
else:
    time = ((h2-1)-h1)*60
    time += (m2+60)-m1

if time < k:
    print(0)
else:
    print(time-k)

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

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

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

if t >= k:
  print(t - k)

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

HH = (H2 - H1) * 60
MM = M2 - M1

print(HH + MM - K)

Solution (Python):
A,B,C,D,E=map(int,input().split())
F=A*60+B
G=C*60+D
H=G-F
I=H-E
print(I)

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

Solution (Python):
h, m,h2, m2,k = map(int, input().split())
mp=0
while True:
    m+=1
    mp+=1
    if m==60:
        h+=1
        m=0
    if h==h2 and m==m2:
        break
print(mp-k)

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

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

if K>=total:
    print(0)
else:
    print(total-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())
t=(h2-h1)*60+(m2-m1)
print(t-k)

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

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

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

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

ans = max(0,(t2 - k) - t1)

print(ans)

Solution (Python):
h0, m0, h1, m1, k = map(int, input().split())

p0 = h0 * 60 + m0
p1 = h1 * 60 + m1

q = p1 - k



print(max(q - p0,0))

Solution (Python):
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
d = [int(s) for s in stdin.readline().rstrip().split()]
h1 = d[0]
m1 = d[1]
h2 = d[2]
m2 = d[3]
k = d[4]
if h1 > h2:
    print(0)
elif h2 == h1:
    num = m2-m1
    if num <= 0:
        print(0)
    else:
        if (num-k) <= 0:
            print(0)
        else:
            print(num-k)
else:
    minu = m2-m1
    if minu < 0:
        res = (h2-h1-1)*60+(minu+60)
        if (res-k) <= 0:
            print(0)
        else:
            print(res-k)
    else:
        res = (h2-h1)*60+(minu)
        if (res-k) <= 0:
            print(0)
        else:
            print(res-k)

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

Solution (Python):
H1,M1,H2,M2,K = map(int, input().split())
H1_t = H1*60+M1
H2_t = H2*60+M2
time = max(H1_t,H2_t) - min(H1_t,H2_t)
if time > K:
    print(time - K)
else:
    print(0)

Solution (Python):

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

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

h = H_2-(H_1+1)
m = 60-M_1+M_2

print(h*60+m-K)

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


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

Solution (Python):


def main():
    H1, M1, H2, M2, K = tuple(int(c) for c in input().split(' '))

    dh = (H2 - H1) * 60
    dm = M2 - M1
    delta = dh + dm

    print(delta - K)

if __name__ == "__main__":
    main()

Solution (Python):
h,m,H,M,k = map(int,input().split())

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

ans = t2 - t1 - k
print(ans)

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

Solution (Python):
a,b,x,y,k=map(int,input().split())
min=(x*60+y)-(a*60+b)
print(min-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())

su = 0
h1 += 1
su += (h2 - h1) * 60
su += (60 - m1) + m2
print(su-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,k = map(int,input().split())
time = (h2*60 + m2) - (h1*60 + m1) -k
print(time)

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

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

last_start = end - k

ans = last_start - begin

print(ans)

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

Solution (Python):
h_1, m_1, h_2, m_2, k = map(int, input().split())

wake_time = (h_2 - h_1) * 60 - m_1 + m_2
print(wake_time - k)

Solution (Python):
h, m, H, M, K = map(int, input().split())

print(H*60 +M - ( h*60 +m  + K ))

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

Solution (Python):

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


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

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

sum1 = i[0] * 60 + i[1]
sum2 = i[2] * 60 + i[3]
ans = sum2 - sum1 - i[4]

print(ans)

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

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

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

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

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

Solution (Python):
h, m, i, n, k = map(int, input().split())

fun1 = 60 * h + m
fun2 = 60 * i + n

sa = fun2-fun1

if sa > k:
    ans = sa -k
else:
    ans = 0

print(ans)

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

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

t = hm2 - k

ans = t - hm1

print(ans)

Solution (Python):
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

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

def read_s_list_loop(n):
    return [input() for _ in range(n)]


H1,M1,H2,M2,K = read_int_map()

h = H2 - H1
m = M2 - M1

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

Solution (Python):
h_1,m_1,h_2,m_2,k=map(int,input().split())

cnt=(h_2*60+m_2)-(h_1*60+m_1)

print(cnt-k)

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
hour=h2-h1
if hour<0:
    hour+=24
minute=m2-m1
time=hour*60+minute
print(time-k)

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

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, k = map(int,input().split())
st = h1*60 + m1
sto = h2*60 + m2

if st < sto:
    if sto-st-k > 0:
        print(sto-st-k)
    else:
        print(0)

else:
    if sto+24*60 - st -k > 0:
        print(sto+24*60 - st -k)
    else:
        print(0)

Solution (Python):
h_1,m_1,h_2,m_2,k = map(int,input().split())

judge = h_2*60+m_2 - (h_1*60+m_1)
if judge - k>=0:
  ans = judge - k
else:
  ans = 0

print(ans)

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

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

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

a1 = H1 * 60 + M1
a2 = H2 * 60 + M2

ans = a2 - a1 - K
print(ans)

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