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):
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())
print(60*(H2-H1)+M2-M1-K)

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

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

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

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

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

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

Solution (Python):
 
list = input().split()
 
m1 = int(list[0])*60 + int(list[1])
m2 = int(list[2])*60 + int(list[3])

    
ans = m2 - m1
print(ans-int(list[4]))

Solution (Python):

 
list = input().split()
 
m1 = int(list[0])*60 + int(list[1])
m2 = int(list[2])*60 + int(list[3])

    
ans = m2 - m1
print(ans-int(list[4]))

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

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

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

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

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

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

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

Solution (Python):
import datetime
h,m,eh,em,k = map(int,input().split())
start = h*60 + m
end = eh*60 + em
if end - start > k:
    print(end - k - start)
else:
    print(0)

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

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

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

print(end - e - start)

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

Solution (Python):
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    H1, M1, H2, M2, K = map(int, input().split())
    if M2 >= M1:
        time = (H2 - H1) * 60 + M2 - M1
    else:
        time = (H2 - H1 - 1) * 60 + M2 + 60 - M1
    answer = max(time - K, 0)

    print(answer)


if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):
import math
import re
import copy

h1,m1,h2,m2,k = map(int,input().split())
w1 = h1*60 + m1
w2 = h2 * 60 + m2
w3 = (w2-w1+24*60)%(24*60)
w3 = w3 - k
print(w3)

Solution (Python):
import math
import re
import copy

h1,m1,h2,m2,k = map(int,input().split())
w1 = h1*60 + m1
w2 = h2 * 60 + m2
w3 = (w2-w1+24*60)%(24*60)
w3 = w3 - k
print(w3)

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


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

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

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

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

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((H2-H1)*60+M2-M1-K)

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

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

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

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

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

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


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import sys











stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

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

main()

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

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

Solution (Python):
a,b,c,d,k = map(int,input().split())
t = c*60+d - (a*60+b)
print(max(0,t-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())

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

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

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

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

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

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

Solution (Python):
import math

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

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    
    
    H1, M1, H2, M2, K = [int(x) for x in sys.stdin.readline().split()]  
    
    
    
    
    

    logger.debug('{}'.format([]))

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


if __name__ == "__main__":
    resolve()





import sys
from io import StringIO
import unittest


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)

Solution (Python):
(wake_h, wake_m, sleep_h, sleep_m, k) = list(map(int, input().split()))

wake_m_all = wake_h * 60 + wake_m
sleep_m_all = sleep_h * 60 + sleep_m
sleep_m_all -= k
print(sleep_m_all - wake_m_all)

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

print(max(0, time2 - time1 - K))

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

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *





































def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	H1, M1, H2, M2, K = inputMap()

	tmp1 = H1 * 60 + M1
	tmp2 = H2*60 + M2

	ans = tmp2 - tmp1 - K

	print(max(0,ans))






def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok





def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None




def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)




def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y




def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv



def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)



if __name__ == "__main__":
	main()

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())
T1, T2 = (H1 * 60 + M1), (H2 * 60 + M2)
print("{}".format((T2 - K) - T1))

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

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

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

if a==c:
    t=d-b
    if e<=t:
        print(t-e)
    else:
        print(0)
    
if c>a:
    if b>d:
        t=60*(c-a)-b+d
        if e<=t:
            print(t-e)
        else:
            print(0)
        
        
    if b<=d:
        t=(c-a)*60+d-b
        if e<=t:
            print(t-e)
        else:
            print(0)

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

Solution (Python):
h1, m1, h2, m2, K = list(map(int, input().split()))
if (h2 - h1)*60 + (m2-m1) < K:
    print('{}'.format(0))
else:
    print('{}'.format((h2 - h1)*60 + (m2-m1) - K))

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

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

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

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

if start_duration_min > 0:
	print(start_duration_min)
else:
	print(0)

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

print(((abs(h1-h2)*60)-(m1-m2)) - K)

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

print(time-k)

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

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

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

Solution (Python):
def main():
    H1,M1,H2,M2,K = [int(x) for x in input().split()]
    if M2 >= M1:
        diff = (H2-H1)*60 + M2-M1
    else:
        diff = (H2-H1)*60 + 60-M1+M2 -60
    if diff <= 0:
        print(0)
    else:
        print(diff - K)

if __name__ == '__main__':
    main()

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

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

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))


def resolve():
    h1,m1,h2,m2,k = mi()
    res = convert(h2,m2) - convert(h1,m1) - k
    print(res)

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

if __name__ == "__main__":
    resolve()

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

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

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

if c*60+d-a*60-b<k:
    print(0)
else:
    print(c*60+d-a*60-b-k)

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



def linput(_t=int):
    return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():
    
    
    h,m,H,M,K = linput()

    res = 60*H + M - 60*h - m - K

    print(res)
    
    

main()

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

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

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

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

print(a2-a1-k)

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

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

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

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

fin = h2 * 60 + m2

st = h1 * 60 + m1

ans = fin - st - k 

print(max(0,ans))

Solution (Python):
from datetime import datetime,timedelta

a=input().split()
a=[int(_) for _ in a]

t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(int(ans))

Solution (Python):



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


if m_2-k>=0:
    m_2 -= k
else:
    tmp = k - m_2
    m_2 = 60 - tmp
    h_2 -= 1
tmp_1 = h_1 * 60 + m_1
tmp_2 = h_2 * 60 + m_2


ans = tmp_2 - tmp_1


print(ans)

Solution (Python):


import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

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

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

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

L = (C - A) * 60 + (D - B)

print(L - E)

Solution (Python):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


a,b,c,d,k=mp()
print(c*60+d-a*60-b-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):









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

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


def main():
    print(solve())


if __name__ == "__main__":
    main()

Solution (Python):


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

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

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

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

print(60*(eh-sh) + em-sm-k)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h1,m1,h2,m2,k = LI()
    m1 += h1 * 60
    m2 += h2 * 60

    return m2 - m1 - k

print(main())

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

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

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

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

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

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

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

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, open(0).read().split())
diff = (H2-H1) * 60 + (M2-M1)
print(diff-K)

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

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

print(total_time-k)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    h1,m1,h2,m2,k=map(int,readline().split())
    print(max(0,(h2-h1)*60+(m2-m1)-k))
    
if __name__=="__main__":
    main()

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

hk = K//60
mk = K%60

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

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

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

ans = s - e - k
print(ans)

Solution (Python):
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case 


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


if __name__ == "__main__":
    h1, m1, h2, m2, k = arr_in()
    out(solve(h1, m1, h2, m2, k))

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

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

if __name__ == "__main__":
    main()

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

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

Solution (Python):
h1,m1,h2,m2,k=[int (x) for x in input().split()]
h3=h1*60
h4=h2*60
a=m1+h3
b=m2+h4
c=b-a
if k>c:
  print(0)
else:
  print(c-k)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
from math import floor,ceil,sqrt,factorial,log
from heapq import heapify, 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 decimal import Decimal
inf = float('inf')
mod = 1000000007

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

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

if t2 > t1:
    ans = t2 - t1 - k
    if ans < 0:
        ans = 0
    print(ans)
else:
    ans = 24 - t1 + t1
    if ans < 0:
        ans = 0
    print(ans)

Solution (Python):
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    
    check=[False for _ in range(n)]
    check[s]=True
    
    queue=deque([s])
    visited_num=1

    
    
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        
        if len(queue)==0:
            
            
            return color

        now_vertex=queue.popleft()
        
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color




ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))





a=input_list()

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

Solution (Python):

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

H1, M1, H2, M2, K = map(int, read().split())
start = H1 * 60 + M1
end = H2 * 60 + M2

gap = end - start

res = gap - K

print(res)

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

Solution (Python):
import sys

"""
H1時M1分起床
H2時M2分就寝
K分勉強
"""
 
H1, M1, H2, M2, K = map(int, sys.stdin.read().split())
 
awake_time = H1 *60 + M1
sleep_time = H2 *60 + M2
start_limit_time = sleep_time - K
can_study_time = start_limit_time - awake_time
 
print(can_study_time)

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

Solution (Python):

import collections
import itertools as it
import math

 


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





import datetime as dt
dt1 = dt.datetime.strptime(f'{h1}:{m1}', '%H:%M')
dt2 = dt.datetime.strptime(f'{h2}:{m2}', '%H:%M')
td = dt2 - dt1
print(td.seconds // 60 - k)

Solution (Python):


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

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

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

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

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

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

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

print((end - K) - start)

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

import datetime

time1 = datetime.datetime(2020,5,5,n[0],n[1])
time2 = datetime.datetime(2020,5,5,n[2],n[3])

time3 = time2 - time1

time3=int(time3.seconds)

result=int(time3/60)
summary = result - n[4]

print(summary)

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

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

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

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

Solution (Python):
import datetime

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


if __name__ == "__main__":
    main()

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

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

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

if __name__ == '__main__':
    solve()

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

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

print(a2 - a1 - k)

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

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

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

print(TIME-K)

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

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

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

x = 60*a + b
y = 60*c + d

print(y-x-k);

Solution (Python):
from datetime import datetime

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

t1=datetime(2020,5,30,H1,M1,0)
t2=datetime(2020,5,30,H2,M2,0)
d=t2-t1
print(d.seconds//60-K)

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

x = 60*a + b
y = 60*c + d

if y>x:
    print(y-x-k);
else:
    print(1440+y-x-k);

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

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

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

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

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

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

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

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

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

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

if __name__ == '__main__':
    print(study_time(h1, m1, h2, m2, k))

Solution (Python):
def main():
    H1, M1, H2, M2, K = (int(i) for i in input().split())
    h = H2 - H1
    m = M2 - M1
    ans = h*60 + m - K
    if ans > 0:
        print(ans)
    else:
        print(0)


if __name__ == '__main__':
    main()

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

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

def main():
    h1,m1,h2,m2,K = map(int, readline().split())

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

    ans = sleep - K - wakeup
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    H1, M1, H2, M2, K = map(int, input().split())
    h = H2 - H1
    m = M2 - M1
    print(max(0, h * 60 + m - K))
if __name__ == "__main__":
    main()