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

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

H1 = h1 * 60
H2 = h2 * 60
res = H2+m2-k-H1-m1
print(res)

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

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

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

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

print(minute)

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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


from datetime import timedelta, datetime

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

a = h1 * 60 + m1
b = h2 * 60 + m2
d =b - a


print(d - k)

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

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

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

print(a-K)

Solution (Python):
import sys
input = sys.stdin.readline
import math
a,b,c,d,e = map(int,input().split())
print(max((c-a)*60+(d-b)-e,0))

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

hour = H2 - H1
min = M2 - M1

if min < 0:
    hour -= 1
    min += 60

res = hour * 60 + min - K
print(res)

Solution (Python):
from numba import njit


@njit
def main(h, m, H, M, K):
    return max((H-h)*60+(M-m)-K, 0)


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


print(main(h, m, H, M, 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())
hoursa=H2-H1
minsa=M2-M1
tmp=hoursa*60+minsa
ans=tmp-K
print(ans)

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

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

ans = t2 - t1 - k
if ans < 0:
    ans = 0

print(ans)

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

Solution (Python):

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

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

ans = end-start-k

print(ans)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]





A, B, C, D, K = mi()

print(C*60+D-A*60-B-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(t2-t1 - k)

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

b = a[0]*60 + a[1]
c = a[2]*60 + a[3]

if c-b<a[4]:
    print(0)
else:
    print(c-b-a[4])

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

Solution (Python):





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




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

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

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

Solution (Python):
import sys
from collections import deque
import copy
def main():
    H, M, h, m, K = map(int, input().split())
    ans = 0
    while True:
        if H == h and M == m:
            break
        M += 1
        ans += 1
        if M == 60:
            M = 0
            H += 1
    print(ans - K)


if __name__ == '__main__':
    main()

Solution (Python):



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

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

if H1==H2:
    x=M2-M1
    ms=x-K
else:
    ms=(60-M1)+(H2-H1-1)*60+M2-K
print(max(0, ms))

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

H = H2 - H1
M = M2 - M1

time = H*60 + M

print(time-K)

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

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

sa = m2 - m1

print(sa - k)

Solution (Python):
h1,m1,h2,m2,k=map(int,input().split())
if ((h2-h1)*60+(m2-m1)-k)>=0:
    print((h2-h1)*60+(m2-m1)-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):
import numpy as np
import math
import collections

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

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

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

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

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

getup = H1*60 + M1
gotobed = H2*60 + M2

print(gotobed - getup - K)

Solution (Python):

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

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

print(a)

Solution (Python):


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

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

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

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


if __name__ == "__main__":
    main()

Solution (Python):
gh,gm,sh,sm,k=map(int,input().split())
print(sh*60+sm-(gh*60+gm)-k)

Solution (Python):

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




count = 0

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

print(count)

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

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

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

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

Solution (Python):

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

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

diff=time2-time1

print(diff-k)

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

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

print(max(0, ans))

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

b=H*60+M
a=h*60+m

print(a-b-K)

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

Solution (Python):
from sys import stdin
import sys
import math

A, B, C, D, E = [int(x) for x in stdin.readline().rstrip().split()]


x=A*60+B
y=C*60+D
print(y-x-E)

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

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

print(ans)

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

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

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

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

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

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

if j2-j1 < k:
    print(0)
else:
    a = j2-j1-k
    print(a)

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

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

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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

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

print(max(0,m-k))

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]


H1, M1, H2, M2, K = map(int, input().split())
start_time = H1*60 + M1
end_time = H2*60 + M2

print(end_time - start_time - K)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
h1, m1, h2, m2, k = M()
a = h1*60 + m1
b = h2*60 + m2
print(max(b-k-a, 0))

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

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


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

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    h1,m1,h2,m2,k = map(int, input().split())
    rem = h2*60+m2-h1*60-m1
    print(rem-k)
    


if __name__ == '__main__':
    main()

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

Solution (Python):
from sys import stdin, stdout


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

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

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

    print(start - K)


if __name__ == '__main__':
    main()

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

mae = H1*60 + M1
ato = H2*60 + M2
tmp = ato - mae

if K > tmp:
    print(K)
else:
    print(tmp - 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 = list(map(int, input().split()))

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

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

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


if __name__ == '__main__':
    main()

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

m = 60 +X[3] - X[1]
h = X[2] - X[0] -1

print(h*60 +m - X[4])

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

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

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

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

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

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

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

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

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

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

if x<=k:
    print(0)
else:
    print(x-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())

hour = h2 - h1
mins = m2 - m1

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

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

print(inh[2]*60+inh[3]-inh[0]*60-inh[1]-inh[4])

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

Solution (Python):
import sys, math,os
from io import BytesIO, IOBase
from bisect import bisect_left as bl, bisect_right as br, insort

from collections import defaultdict as dd, deque, Counter

def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
sys.setrecursionlimit(100000)
from fractions import Fraction
INF = float('inf')
mod = 998244353


def main():

    h1,m1,h2,m2,k=mdata()
    out(h2*60+m2-h1*60-m1-k)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    a, b, c, d, k  = i_map()

    h = c - a
    m = d - b

    ans = h * 60 + m

    print(ans-k)
            
if __name__ == '__main__':
    main()

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

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

Solution (Python):

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

B = H1 * 60 + M1
A = H2 * 60 + M2
if H1 > H2:
    A += 24 * 60

print(A-B-K)

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

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

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

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

print(t - k)

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

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

wake = 60 * h1 + m1
sleep = 60 * h2 + m2
waking = sleep - wake
res = waking - k
print(res)

Solution (Python):



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

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

Solution (Python):
import numpy as np

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

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

ans = T2 - K -T1
print(ans)

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

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

print(time)

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

Solution (Python):
h,m,h1,m1,k=map(int,input().split())
if m1<m:
    m1+=60
    h1-=1
print(max(0,(h1-h)*60+(m1-m)-k))

Solution (Python):

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



if __name__ == '__main__':
    main()

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

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

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

print(awake_minutes - k)

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

Solution (Python):
def main():
  h1,m1,h2,m2,k=map(int,input().split())
  a=60*(h2-h1)+(m2-m1)
  print(max(0,a-k))
if __name__=='__main__':
  main()

Solution (Python):
import numpy as np
h1, m1, h2, m2, k = np.array(list(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())

start = h1 * 60 + m1
goal = h2 * 60 + m2 - K

if start < goal:
    print(goal - start)
else:
    print(0)

Solution (Python):
import sys
input = sys.stdin.readline
RS = input
RI = lambda x=int: x(RS())
RA = lambda x=int: map(x, RS().split())
RSS = lambda: RS().split()


def solve():
    start = h1*60 + m1
    end = h2*60 + m2
    print(end- k - start)
    return



h1, m1, h2, m2, k = RA()
solve()

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

if -(a*60+b)+(c*60+d)-e <0:
        print(0)
        exit()
print(-(a*60+b)+(c*60+d)-e)

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    h1, m1, h2, m2, k = [int(x) for x in input().strip().split()]
    t1 = 60 * h1 + m1
    t2 = 60 * h2 + m2
    if t2 < t1:
        t2 = 60 * (h2 + 24) + m2
    print(t2 - t1 - k)
    
if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):


"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()


    
def solve():
    a,b,c,d,k = invr()
    print(c * 60 + d - a * 60 - b - k)
        


 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))


def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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

Solution (Python):
fH, fM, sH, sM, K = map(int, input().split())

print(60 *(sH - fH) + sM -fM -K)

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

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H1,M1,H2,M2,K = LI()
print(60*(H2-H1)+(M2-M1)-K)

Solution (Python):

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




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

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

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

print(end - front-k)

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

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

start = H1*60+M1
end = H2*60+M2
finish = end - K
answer = finish - start
print(answer)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") 

a,b,c,d,h = map(int,input().split())
wake_up = 60*a+b
start_time = 60*c+d - h
print(start_time-wake_up)

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

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
length = (h2 - h1) * 60 + m2 - m1
print(length - 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):
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())
h = h2-h1 
m = m2-m1 
m += h*60
m -= k
print(m)

Solution (Python):
H1, M1, H2, M2, K = list(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())

time1 = h_1 * 60 +m_1

time2 = h_2 * 60 +m_2

time_dif = time2 - time1

print(time_dif-k)

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

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


if __name__ == '__main__':
    main()

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

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

x = h1 * 60 + m1
y = h2 * 60 + m2

ans = abs((y-x)-k)
if ans < 0:
    ans = 0
print(ans)

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

Solution (Python):
h1, m1, h2, m2, k = map(int, input().split())
if h2 < h1:
    h2 += 24
x1 = h1 * 60 + m1
x2 = h2 * 60 + m2
print(x2 - x1 - 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):
h1,m1,h2,m2,k=map(int, input().split())
m1=60-m1
h1=h1+1
ans=(h2-h1)*60
ans=ans+m1+m2
print(ans-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())
a = h1*60+m1
b = h2*60+m2
print(b-a-k)

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

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

resolve()

Solution (Python):
import sys, random, math
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20



    t = 1
    
    for _ in range(1, t+1):
    
        
        h1, m1, h2, m2, k = map(int, input().split())
        m1 += h1*60
        m2 += h2*60
        print(m2-m1-k)
        
        
main()

Solution (Python):
def mips():
    return map(int,input().split())
def ii():
    return int(input())

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

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

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

Solution (Python):
def resolve():
    '''
    code here
    '''
    H1, M1, H2, M2, K = [int(item) for item in input().split()]
 
    H = H2 -H1
    M = M2 -M1
    print(H*60 + M - K)
if __name__ == "__main__":
    resolve()

Solution (Python):
def solve():
  h1, m1, h2, m2, k = list(map(lambda x: int(x), input().split()))
  total_time = (h2 - h1) * 60 + m2 - m1
  return total_time - k

print(solve())

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

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

Solution (Python):


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

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

print(min - K)

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

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

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

hour = h_2 - h_1

answer = hour * 60 + m_2 - m_1 - k

print(answer)

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

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

print((HM2 - HM1)-K)

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

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

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

M3 = M2 - M1
if M3 <= 0:
    M3 += 24 * 60

print(M3 - K)

Solution (Python):

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

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

if b < d:
    m = (c-a)*60 + (d-b)
else:
    m = (c-a-1)*60 + (60 - (b-d))

print(m-e)

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

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


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

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

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

print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main(): 
    a,b,c,d,K = map(int,input().split())
    ans = 0
    if a == c:
        ans = (d - b - K)
    else:
        a += 1
        ans += 60 - b
        ans += (c - a) * 60 + d
        ans -= K
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
[HS,MS,HE,ME,T]=[int(i) for i in input().split()]
print(max(HE*60+ME-HS*60-MS-T,0))

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

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

naga -= k

print(naga)

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

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

H1,H2 = 60*H1,60*H2

AM = H1+M1
PM = H2+M2
ans = PM-AM-K
print(ans)

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

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

ans = M2-M1-K
print(ans)

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

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