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 = list(map(int,input().split()))

h = h2 - h1

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

t = (h * 60) + m

print(t-k)

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

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

if ans < 0:
  ans = 0

print(ans)

Solution (Python):

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

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

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

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

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

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

Solution (Python):
import numpy as np

l = list(map(int, input().split()))
l[0]*=60
l[2]*=60
o=[0 ,0]
o[0]=l[0]+l[1]
o[1]=l[2]+l[3]
p=o[1]-o[0]-l[4]
print(p)

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

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

Solution (Python):
h1,m1,h2,m2,k=[int(x) for x in input().split()]
z=(abs(h2-h1))*60
time=z-m1+m2
print(time-k)

Solution (Python):
import datetime

l = list(map(int, input().split()))
A = l[0]
B = l[1]
H = l[2]
M = l[3]
K = l[4]

m1 = A*60 + B
m2 = H*60 + M
delta = m2-m1 
answer = delta - K
print(answer)

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

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

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

dH = H2-H1
dM = M2-M1

dm = 60*dH+dM

print(dm-K)

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

h = h2 - h1
m = m2 - m1

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

ans = h * 60 + m - k
print(ans)

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

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

print(times - k)

Solution (Python):


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

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

print("{}".format(okiru-K))

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

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

if t2 - t1 <= K:
    print(0)
else:
    print(t2-t1-K)

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

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue

Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  
    h1, m1, h2, m2, k = map(int, input().split())
    if h1 > h2:
        h2 += 24
    h = h2 - h1
    if m1 > m2:
        m2 += 60
        h-=1
    m = m2 - m1
    print(h*60 + m - k)
if __name__ == "__main__":
    main()

Solution (Python):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")





h1,m1,h2,m2,k=LI()
t1=60*h1+m1
t2=60*h2+m2
print(max(0,-t1+t2-k))

Solution (Python):


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

t = 0
if l[3] >= l[1]:
    t += (l[2]-l[0]) * 60
    t += l[3]-l[1]
else:
    if l[0]+1 == l[2]:
        t += l[3]-l[1]+60
    else:
        t += (l[2]-l[0]-1) * 60
        t += l[3]-l[1]+60

ans = max((t-l[4]),0)
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


h1, m1, h2, m2, k = Is()
start = h1*60+m1
end = h2*60+m2
time = end - k - start
if time < 0:
    time += 24*60

print(time)

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

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

m = hd * 60 + md

print(m-k)

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):
h_1, m_1, h_2, m_2, k = map(int, input().split())
time_m = h_2*60 + m_2 - (h_1*60 + m_1) - k
if time_m >= 0:
    print(time_m)
else:
    time_m = 24*60 - (h_2*60 + m_2) + h_1*60 + m_1 - k
    print(time_m)

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

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

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

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

if T1 > T2:
    T2 += 24*60

ans = (T2 - K) - T1

print(ans)

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

if h1<=h2:
  h1m=h1*60+m1
  h2m=h2*60+m2
  print(h2m-h1m-k)
else:
  h1m=h1*60+m1
  h2=(h2+12)*60+m2
  print(h2m-h1m-k)

Solution (Python):
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


h1, m1, h2, m2, k = MI()
t = h2 * 60 + m2
s = h1 * 60 + m1
print(max(0, t-k-s))

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

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

kaisi = okiteru - int(K)

print(kaisi)

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





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

print(a-k)

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

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

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

Solution (Python):
S = input()
s = S.split()

H1 = int(s[0])
M1 = int(s[1])
H2 = int(s[2])
M2 = int(s[3])
K = int(s[4])

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

print(study_minutes)

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

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

Solution (Python):

def main():
    line = list(map(int,input().split()))
    H1 = line[0]
    M1 = line[1]
    H2 = line[2]
    M2 = line[3]
    K = line[4]
    h = H2-H1
    m = M2 - M1
    if m < 0:
        h -= 1
        m %= 60
    k = h*60+m-K
    print(k)


if __name__ == "__main__":
    main()

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

H = H2 - H1
M = M2 - M1

answer = H*60 + M - K
print(answer)

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

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

print(m-K)

Solution (Python):
import io,sys
sys.setrecursionlimit(10**9)

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

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
h1,m1,h2,m2,k=map(int,input().split())
t1=h1*60+m1
t2=h2*60+m2
if t2<=t1:
  t2+=24*60
t=t2-t1
print(max(0,t-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())
ans = 60 * (h2 - h1) + (m2 - m1) - 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())

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

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







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

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

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

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

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

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

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

Solution (Python):
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json

import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    
    
    H1, M1, H2, M2, K = [int(a) for a in input().split()]
    
    
    s = H1*60+M1
    e = H2*60+M2

    print(e-s-K)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





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

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

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

Solution (Python):
sh, sm, eh, em, K = map(int, input().split())

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

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

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

begin = h2 - k

print(begin-h1)

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

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

print(time-K)

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

Solution (Python):
h1,m1,h2,m2,k=[int(x) for x in input().split()]
t2=h2*60+m2
t1=h1*60+m1
rem=t2-t1
print(rem-k)

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

if M2 - M1 >= 0:
  M = M2 - M1
else:
  M = M2 - M1 + 60
  H -= 1
  
ans = H*60 + M - K

print(ans)

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

print(time-e)

Solution (Python):
from sys import stdin
import math
a=stdin.readline().split()
H1=int(a[0])
M1=int(a[1])
H2=int(a[2])
M2=int(a[3])
K=int(a[4])

if M2>=M1:
    min=M2-M1
    if H2>=H1:
        hour=H2-H1
    else:
        hour=H2+24-H1
else:
    min=M2+60-M1
    if H2-1>=H1:
        hour=H2-1-H1
    else:
        hour=H2+24-1-H1

elapsed=hour*60+min

print(elapsed-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())
getup = h1 * 60 + m1
sleep = h2 * 60 + m2
limit = sleep - k

if limit - getup <= 0:
  print(0)
else:
  print(limit - getup)

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    
    (h1, m1, h2, m2, k) = [int(e) for e in lines[0].split(' ')]

    return (h1, m1, h2, m2, k)

def solve(h1, m1, h2, m2, k):
 
    mins = (h2 * 60 + m2) - (h1 * 60 + m1)

    result = max(mins - k, 0)


    return result

def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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

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

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

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

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

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

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

a=h2-h1 
b=60-m1+m2 
a-=1
t=a*60+b-x
print(t)

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

print(ans)

Solution (Python):
st = input()

l = st.split()
h1, m1, h2, m2, k = int(l[0]), int(l[1]), int(l[2]), int(l[3]), int(l[4])

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

print(time2-time1-k)

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

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

    h1 = H1 * 60 + M1
    h2 = H2 * 60 + M2
    ans = h2 - K - h1

    print(ans)


if __name__ == '__main__':
    main()

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


aa = (h2 + m2 - k) - h1 - m1
print(aa)

Solution (Python):
import sys
data = input().split()
start_hour = int(data[0])
start_min = int(data[1])
end_hour = int(data[2])
end_min = int(data[3])
study_min = int(data[4])
bit_min = (end_hour - start_hour) * 60 + end_min - start_min
ans = bit_min - study_min
print(ans)

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

if M_2 >= M_1:
    H = H_2 - H_1
    M = M_2 - M_1
else:
    H = H_2 - H_1 - 1
    M = 60 - M_1 + M_2

time = 60 * H + M
ans = time - K

print(str(ans))

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

S = int(h1*60+m1)
E = int(h2*60+m2)
print(E-S-k)

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

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

print(ans - k)

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

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

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

time = (60*H2+M2) - (60*H1+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
t3 = t2-k
ans = t3-t1
if ans > 0:
    print(ans)
else:
    print(0)

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

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

print(end-start-num[4])

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

if(m2>=m1):

    time = (h2-h1)*60 + (m2-m1)
else:
    time = 60-m1
    h1+=1
    m1 = 0
    time += (h2-h1)*60 + abs(m2-m1)
print(time-k)

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

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

modh = 24
modm = 60

h1,m1,h2,m2,k = map(int,readline().split())
ans = 0
m1 += k
while True:
    if h1+(m1//modm) < h2:
        ans += 1
    elif h1+(m1//modm) == h2 and m1%modm < m2:
        ans += 1
    else:
        break
    m1 += 1
print(ans)

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

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

res = h*60 + m - k
res = max(0,res)
print(res)

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

if m2 < m1:
    mm = m2 - m1
else:
    mm = m2 - m1

t = (h2 - h1) * 60 + mm

if t < m:
    print(0)
else:
    print(t - m)

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

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

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

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

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

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

print(remain)

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

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

a=h2*60+m2-k

print(a-h1*60-m1)

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

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

diff = end - start

if diff < k:
    print(0)
else:
    ss = end - k
    print(ss-start)

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 = list(map(int,input().split()))

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

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

H1_min = H1*60
H2_min = H2*60
HM1 = H1_min+M1
HM2 = H2_min+M2

HM = HM2 - HM1

if (HM > K):
  print(HM-K)
else:
  print(0)

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

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

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

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

Solution (Python):
if __name__ == "__main__":

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

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

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

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

run_time = active_time-k

print(run_time)

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

hour=h2-h1
minute=m2-m1
if minute<0:
  hour -= 1
  minute=60-m1+m2

ans = hour*60+minute-k
print(ans)

Solution (Python):



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



start_m = (60 * h1) + m1
end_m = (60 * h2) + m2
okiteiru = end_m - start_m





print(okiteiru - k)

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

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

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

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

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

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

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

Solution (Python):
def readInt():
    return list(map(int, input().split()))
    
h_1, m_1, h_2, m_2, k = readInt()
t_1 = h_1*60 + m_1
t_2 = h_2*60 + m_2

w_t = t_2 - t_1
print(w_t-k)

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

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

if j1 > j2:
    j1 += 24*60

ans = j2 - j1 - k

print(ans)

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

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

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

if M1>M2:
    H = H2-H1-1
    M = 60+M2-M1
else:
    H = H2-H1
    M = M2-M1
time = H*60+M
if time>=K:
    print(time-K)
else:
    print(0)

Solution (Python):



if __name__ == "__main__":
    
    INPUT = list(map(int, input().split()))

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


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

    c = a2 - a1 - k


    print(c)

Solution (Python):
h1, m1, h2, m2, k = [int(i) for i in input().split()]
a = h1 * 60 + m1
b = h2 * 60 + m2
print(b - a - k)

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

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

a = time[0] * 60 + time[1]
b = time[2] * 60 + time[3]
ans = b - time[4] - a

print(ans)

Solution (Python):
listA=[] 
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        

b = (listA[0][2]*60 + listA[0][3]) - (listA[0][0]*60 + listA[0][1]) - listA[0][4]
print(b)

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

Solution (Python):
import os, sys

str = input()

a, b, c, d, e = str.split(" ")

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

print(res)

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

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

ans=dif-K
print(ans)

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

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

print(ANS)

Solution (Python):


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

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

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

h1, m1, h2, m2, K = MAP()

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    h1,m1,h2,m2,k = map(int,input().split())
    cnt1 = h1*60 + m1
    cnt2 = h2*60 + m2
    print(max((cnt2-cnt1) - k,0))

Solution (Python):
h1, m1, h2, m2, k = list(map(int, input().split()))
ans = 0
delta = 60 * (h2 - h1)
if m2 > m1:
    delta += (m2 - m1)
else:
    delta -= (m1 - m2)
print(max(0, delta - 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):
a,b,c,d,k=map(int,input().split())
h=c-a
if d>=b:
  m=d-b
else:
  h-=1
  m=60+d-b
ans=60*h+m-k
if ans<0:
  ans=0
print(ans)

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

Hsa = (H2 - H1)*60
Msa = (M2 - M1)

ans = Hsa + Msa - K

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

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

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

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

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

Solution (Python):








import sys,collections

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

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

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

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

print(ans)

Solution (Python):




"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""


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

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

if time <= K:
    print("0")

else:
    print(time-K)

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())
ans = (c-a)*60 + d-b - 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())
time_sum = (H2 * 60 + M2) - (M1 + H1 * 60)
result_time = time_sum - K

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

Solution (Python):
def main ():
  hs, ms, he, me, sm = map(int, input().split())
  
  return (((he - hs) * 60) - ms + me) - sm


print(main())

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

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):
H1,M1,H2,M2,K=map(int,input().split())
time=(H2*60+M2)-(H1*60+M1)
if time>=K:
  ans=time-K
else:
  ans=0
print(ans)

Solution (Python):
a=input()
a0=a.split()
h1=int(a0[0])
m1=int(a0[1])
h2=int(a0[2])
m2=int(a0[3])
k=int(a0[4])
t1=60*h1+m1
t2=60*h2+m2
t=t2-t1
print(t-k)

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

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

H1,M1,H2,M2,K=(int(x) for x in input().rstrip('\n').split())
sta = H1*60+M1
end = H2*60+M2
print(end-sta-K)

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

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

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

print(x-k)

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

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

Solution (Python):
A,B,C,D,E = map(int,input().split())

print( (C-A)*60 -(B-D) -E )

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

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

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

S = H1*60 + M1
L = H2*60 + M2

print(L - S - K)

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