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 math


def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;

if __name__ == "__main__":
    
    h1, m1, h2, m2, k = get_ints()
    if h2 < h1:
        h2 = 24 + h2
    min1 = h1 * 60 + m1
    min2 = h2 * 60 + m2
    print(min2 - min1 - k)



'''
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
>>> DO NOT PLAGIARISE.
TESTCASES:
'''

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

h = h2 - h1
m = m2 - m1

t = h*60 + m

print(t - k)

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

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

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

res = f*60 + g - a*60 - b
print(res)

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

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 = H2*60 + M2 - H1*60 - M1 - K
print(ans if ans > 0 else 0)

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


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

print(ans)

Solution (Python):
A,B,C,D,E=map(int,input().split())
K1= A*60+B
K2= C*60+D
if abs(K1-K2)>=E:
    print(abs(K1-K2)-E)
else:
    print(0)

Solution (Python):

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

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

main()

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

Solution (Python):
import numpy as np




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

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

t = time2-k
print(t-time1)

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

H = H2-H1
M = M2-M1

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

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

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

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

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

    if H + M - K > 0:
        print(H + M - K)
    else:
        print(0)

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

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

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

Solution (Python):

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

start = h1*60+m1
end = h2*60+m2
total = end - start - k

print(total)

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

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

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

end = h2*60+m2
stt = h*60+m

print(end-stt-k)

Solution (Python):
import sys

def calcLength(H1, M1, H2, M2):
    return (H2-H1)* 60 + (M2-M1)


if(__name__ == "__main__"):
    HMKList = input().strip().split()
    H1 = int(HMKList[0])
    M1 = int(HMKList[1])
    H2 = int(HMKList[2])
    M2 = int(HMKList[3])
    K = int(HMKList[4])
    Time = calcLength(H1, M1, H2, M2)
    StudyTime = Time-K
    print(StudyTime)

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

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

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

Solution (Python):
import sys
from functools import lru_cache
 

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())

h1,m1,h2,m2,k=reads()
limit=(h2-h1)*60+m2-m1
res=0
if limit-k>=0:
    limit-=k
else:limit=0
print(limit)

Solution (Python):
def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    h = h2 - h1
    if h < 0:
        h += 24
    m = m2 - m1
    if m < 0:
        m += 60
        h -= 1

    print(h * 60 + m - k)

resolve()

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

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

Solution (Python):
import string
import itertools as it
import math
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))


def sum_comb(n):
    result = []
    data = range(1,n+1)
    for i in range(len(data)):
        for j in range(i, len(data)):
            for k in range(j, len(data)):
                result.append([data[i], data[j], data[k]])
    return result

H1,M1,H2,M2 ,K = nums()
start = H1 * 60 + M1
end = H2 * 60 + M2
t = end - start
print(t - K)

Solution (Python):
[[h1, m1, h2, m2, k]] = [[*map(int, t.split())] for t in open(0)]

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

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

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

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

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

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


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

Solution (Python):






"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import os
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from io import BytesIO, IOBase
from typing import Dict, List, Optional, Set, Tuple


def solve(values: List[int]) -> int:
    h1, m1, h2, m2, k = values
    wake_time = h1 * 60 + m1
    sleep_time = h2 * 60 + m2
    return sleep_time - k - wake_time


def do_job(stdin, stdout):
    "Do the work"
    LOG.debug("Start working")
    
    values = list(map(int, stdin.readline().split()))
    
    
    
    result = solve(values)
    print(result, file=stdout)


def print_output(testcase: int, result, stdout) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case 
    
    


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


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("L%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(IOWrapper(sys.stderr))
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None

if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    stdin = IOWrapper(sys.stdin)
    stdout = IOWrapper(sys.stdout)
    do_job(stdin, stdout)
    stdout.flush()
    for h in LOG.handlers:
        h.flush()
    return 0


if __name__ == "__main__":
    sys.exit(main())

Solution (Python):
a,s,d,f,g=map(int,input().split())
ans=0
ans=(d-a)*60+(f-s)-g
print(ans)

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

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

Solution (Python):
h1, m1, h2, m2, k = map(int, 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())

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

Solution (Python):
h_1,m_1,h_2,m_2,k=map(int,input().split())
h_1*=60
h_2*=60
hour1=h_1+m_1
hour2=h_2+m_2
hour=hour2-hour1-k
if hour<0:
    hour=0
print(hour)

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

Solution (Python):
import sys
max_int = 1000000001  
min_int = -max_int

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

diff = (h2 - h1) * 60 + m2 - m1
if diff < 0:
    diff += 60 * 24

print(max(diff - k, 0))

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

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

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

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

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

Solution (Python):
def time_to_min(H, M):
  return H * 60 + M


def resolve():
  H1, M1, H2, M2, K= map(int, input().split(" "))
  start = time_to_min(H1, M1)
  end = time_to_min(H2, M2)
  print(end - start - K)

if __name__ == "__main__":
  resolve()

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

f = (a*60)+b
g = (c*60)+d

print((g-f)-e)

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

Solution (Python):
row = [int(i) for i in input().split()]
h1,m1,h2,m2,k = row[0],row[1],row[2],row[3],row[4]
waketime = (h2 - h1) * 60 + (m2 - m1) - k
print(waketime)

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

if d >= b:
    s = 60*(c-a) + d - b
else:
    s = 60*(c-a)  - (b -d) 
ans = s-k
print(ans)

Solution (Python):
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    h1, m1, h2, m2, k = geta(int)

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

    print(diff if diff > 0 else 0)


if __name__ == "__main__":
    main()

Solution (Python):
n = input().split()

s = int(n[0])*60+int(n[1])
e = int(n[2])*60+int(n[3])
t = e-s

print(t - int(n[4]))

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

if k <= m2:
    m2 -= k
else:
    h2 -= 1
    m2 += 60 - k

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

print(ans)

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

Solution (Python):
i = list(map(int, input().split()))
H1 = i[0]
M1 = i[1]
H2 = i[2]
M2 = i[3]
studyM = i[4]

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

print(minute -studyM)

Solution (Python):
if __name__ == '__main__':
    H1, M1, H2, M2, K = map(int, input().strip().split(" "))

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

Solution (Python):











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



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

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

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

Solution (Python):
hn = [int(i) for i in  input().split()]
hs = hn[0]
ms = hn[1]
he = hn[2]
me = hn[3]
k = hn[4]

sta = hs * 60 + ms
end = he * 60 + me

print(end-sta-k)

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

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

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

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

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

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

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

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

if m_2 >= m_1:
    min = m_2 - m_1
else:
    min = 60 + m_2 - m_1
    h_2 -= 1

hour = h_2 - h_1

print(hour*60 + min - k)

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

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

T1 = H1 * 60 + M1
T2 = H2 * 60 + M2
A = T2 - T1
print(A - 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):
import sys


def main():
    input = sys.stdin.buffer.readline
    h_1, m_1, h_2, m_2, k = map(int, input().split())
    min = h_2 * 60 + m_2 - (h_1 * 60 + m_1)
    print(min - k)


if __name__ == '__main__':
    main()

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

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

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

def resolve():

    sh, sm, gh, gm , k = map(int,input().split())

    team = (gh*60 + gm) - (sh*60 + sm)

    print(team - k)



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
ans = ans + m2 - m1
print(ans - k)

Solution (Python):

import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

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

    

if __name__ == '__main__':
    main()

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

h = h * 60 + m

h2 = h2 * 60 + m2

print(h2 - h - k)

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

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

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

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):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

h,m,hh,mm,k = map(int, input().split())

ss = h*60+m

ff = hh*60+mm

if ff-ss < 0:
    tmp = ff-ss + 24*60
else:
    tmp = ff-ss

ans = tmp - k

print(max(0,ans))

Solution (Python):

import sys


def solve(H: "List[int]", M: "List[int]", K: int):
    hi = 0
    m = M[1] - M[0]
    
    if m < 0:
        hi = 1
        m = m+60

    h = H[1] - H[0] - hi
    if h < 0:
        h+=24
    
    print(h*60+m-K)


    return




def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = [int()] * (2)  
    M = [int()] * (2)  
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  
    solve(H, M, K)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
H1, M1, H2, M2, K = [ int(i) for i in input().strip().split(' ')]
print(H2 * 60 + M2 - (H1 * 60 + M1) - K)

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

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

ans=(h*60+m)-(H*60+M)-K

print(int(ans))

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

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

time1 = 60*H1 + M1
time2 = 60*H2 + M2
time = time2-time1
ans = time - K
if ans < 0:
  print(0)
else:
  print(ans)

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

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

h_1_m=h_1*60+m_1
h_2_m=h_2*60+m_2
min=h_2_m-h_1_m-k
print(min)

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

st = h1*60 + m1
en = h2*60 + m2
t = (en-k)-st
print(t, end="")

Solution (Python):
line = input().rstrip().split()

start = 60*(int(line[0])) + int(line[1])
end = 60*(int(line[2])) + int(line[3])
range = end - start

rag = int(line[4])

answer = end - start -rag
print(answer)

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):
def main():
	h1,m1,h2,m2,k = [int(x) for x in input().split()]
	o1 = h1 * 60 + m1
	o2 = h2 * 60 + m2
	print(max(0, (o2-o1-k)))

main()

Solution (Python):

import sys
input = sys.stdin.readline
H1,M1,H2,M2,K = (int(x) for x in input().split())
m1 =60*H1 +M1
m2 =60*H2 +M2
ans =m2 -K -m1
print(ans)

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):
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(60*c + d - e - 60*a - b)

Solution (Python):
hw,mw,hs,ms,k=map(int,input().split())
waking=(hs*60+ms)-(hw*60+mw)-k
print(max(0,waking))

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

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

print(mins - K)

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

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

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





start = (H1 * 60) + M1
end = (H2 * 60) + M2



goal = end - start - K

print(goal)

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

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

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque


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


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


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


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



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h1, m1, h2, m2, k = map(int, input().split())
h = (h2-h1)*60
m = (m2-m1)
sum = h+m
print(sum-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().split())
print(((h2-h1+24)%24)*60+m2-m1-k)

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

oki = H1*60 + M1
ne = H2*60 + M2

ans = 0
for i in range(oki, ne):
    if i + K < ne:
        ans += 1
print(ans)

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

h = h2 - h1
m = m2 - m1

minutes = h*60 + m

print(minutes-k)

Solution (Python):
def main():
    hs,ms,he,me,k = map(int,input().split())
    h = he - hs
    m = me - ms
    h *= 60
    if m >= 0:
        h += m
    else:
        h += m
    print(h - k)
if __name__=='__main__':
    main()

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

ans=(HH*60+MM)-(H*60+M)-K
print(ans)

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

former = 60 * inputs[0] + inputs[1]
latter = 60 * inputs[2] + inputs[3]

study_time = latter - inputs[4] - former

print(study_time)

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

if m1 <= m2:
    dh = h2 - h1
    dm = m2 - m1
else:
    dh = h2 - h1 -1
    dm = (60-m1) + m2

print(dh * 60 + dm - k)

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

A=a*60+b
C = c*60+d

print(C-A-k)

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

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

Solution (Python):
ah, am, bh, bm, k = map(int, input().split())

ans = int((bh - ah)*60 + (bm - am))
ans -= k;

print(ans)

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

Solution (Python):
import sys
import math
from  collections import defaultdict




def solve(test):
	h1, m1, h2, m2, k = map(int, input().split())
	r1 = h1 * 60 + m1
	r2 = h2 * 60 + m2
	ans = max(0, r2 - r1 - k)
	print(ans)

if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)

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

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

print(ans)

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

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

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

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

if dist > k:
    print(dist-k)
else:
    print(0)

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

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

if m1 > m2:
    m2 += 60
    h2 -=1
    ans_m = m2 - m1
else:
    ans_m = m2 - m1

ans_h = h2 - h1
ans = 60 * ans_h + ans_m

print(ans-k)

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

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

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

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

if m2 < m1:
    h2 -= 1
    m2 += 60

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

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

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

ans = time2 - K - time1
if ans < 0:
    ans = 0

print(ans)

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

print(min - K)

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

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

T = t2 - t1 - K
if T < 0:
  T += 24 * 60

print(T)

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

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

Solution (Python):



def solve(*args: str) -> str:
    h1, m1, h2, m2, k = map(int, args[0].split())
    return str((h2-h1)*60 + (m2-m1) - k)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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

Solution (Python):
def resolve():
    hs, ms, he, me, k = [int(i) for i in input().split()]
    h = he - hs
    m = 0
    if me >= ms:
        m = me - ms
    else:
        h -= 1
        m = 60 + me - ms
    print(h * 60 + m - k)


resolve()

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

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

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

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

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

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

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

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

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

print(TL-K)

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

time = 0

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

print(end-K-start)

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

Solution (Python):

H,M,A,B,K=map(int,input().split())
C=0
C+=(A-H)*60
C+=B-M-K
print(C)

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

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

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

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

print(ans)

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

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

t3 = t2 - k

if t3 - t1 <= 0:
  print(0)
else:
  print(t3-t1)

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

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


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

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

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

print(duration - K)

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

Solution (Python):

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

if __name__ == "__main__":
    main()

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

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

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

print(nagasa - k)

Solution (Python):
n,m,a,b,k=map(int,input().split())
if b < k:
    a-=1
    b+=60
ans = a-n
anss = ans*60+b-m-k
print(str(anss))

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

time1 = 60*H1 + M1
time2 = 60*H2 + M2
time = time2-time1
ans = time - K
if ans < 0:
  print(0)
else:
  print(ans)

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

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

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

if m1>m2:
    h2 -= 1
    m2 += 60

h = h2-h1
m = m2-m1

time = h*60 + m

print(time-k)

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