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
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


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


def main():
    H1, M1, H2, M2, K = readnums()
    H2 -= 1
    M2 += 60
    print((H2 - H1) * 60 + (M2 - M1) - K)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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

if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
def main():
    h,M,h2,M2,K=map(int,input().split())
    left=(h2-h)*60+M2-M
    print(left-K)

main()

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

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read

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

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

t = t2-t1

print(max(t-k,0))

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

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

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

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

    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
A, B, C, D, K = list(map(int,input().split()))
a = 60 * A + B
b = 60 * C + D
c = b - a
ans = c - K
print(ans)

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

Solution (Python):

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    h1,m1,h2,m2,k=MI()
    T=(h2-h1)*60+(m2-m1)
    print(T-k)

main()

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
a,b,c,d,e=MI()
time=60*(c-a)+(d-b)
print(time-e)

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

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
import heapq
import sys

INF = 10 ** 17
MOD = 10 ** 9 + 7
def mint(lis):
    return list(map(int, lis))

def bifind(arr_sorted, x):
    idx = bisect_left(arr_sorted, x)
    if idx == len(arr_sorted):
        return False
    if arr_sorted[idx] == x:
        return True
    else:
        return False
def getyaku(n):
    ret = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return ret

def find(x, a):
    idx = bisect_left(a, x)
    if idx == len(a):
        return False
    if a[idx] == x:
        return True
    else:
        return False

def main():
    
    h1, m1, h2, m2, k = getList()
    diff = h1*60 + m1 - h2*60 - m2
    print(-diff - 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):
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

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

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

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

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

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

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

print(max(0,ans1))

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

H = H2 - H1
M = M2 - M1
time = H * 60 + M

ans = time - K
print(ans)

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

ans = h2 - h1
ans *= 60

ans += m2 - m1

print(ans - k)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

print(E - K - S)

Solution (Python):
import unittest


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


def main():
    h, m, h2, m2, k = map(int, input().split())
    result = solve(h, m, h2, m2, k)
    print(result)


class Test(unittest.TestCase):
    def test_solve(self):
        self.assertEqual(1, 1)


if __name__ == "__main__":
    main()

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

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

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

print(max(0, T2-T1-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())

h_1 = H_1 * 60 + M_1
h_2 = H_2 * 60 + M_2

print(h_2 - K - h_1)

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

Solution (Python):



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

if __name__ == "__main__":
    main()

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

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

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

print(y-x-e)

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

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

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

Solution (Python):
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H1, M1, H2, M2, K = ZZ()
    start = 60 * H1 + M1
    end = 60 * H2 + M2
    print(max(0, end - start - K))

    return

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

from collections import *

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

H1, M1, H2, M2, K = map(int, input().split())
a = f(H1, M1)
b = f(H2, M2)
print(b-K-a)

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

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

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

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((h2 - h1) * 60 + (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):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

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

answer=alist[2]*60+alist[3]-alist[0]*60-alist[1]-alist[4]
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):
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())
a = (h2-h1)*60+m2-m1 
print(a-k)

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

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

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

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

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

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








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

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

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

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


print(main())

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

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(H: "List[int]", M: "List[int]", K: int):
    s = H[0] * 60 + M[0]
    t = H[1] * 60 + M[1]
    ret = t - s - K
    print(ret)
    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):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    H1, M1, H2, M2, K = map(int, readline().split())
    MM1 = H1*60+M1
    MM2 = H2*60+M2
    print(max(MM2-MM1-K, 0))
    return


if __name__ == '__main__':
    main()

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

t1 = H1 * 60 + M1
t2 = H2 * 60 + M2
print(max(0, t2 - t1 - 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 = list(map(int, input().split()))
ans = (h2-h1)*60+m2-m1-k
print(ans)

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

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    H1, M1, H2, M2, K = LI()

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

if __name__ == '__main__':
    resolve()

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

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

def s_in():
    return input()

def n_in():
    return int(input())

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

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

def resolve():
    H1,M1,H2,M2,K=pin()
    t1=H1*60+M1
    t2=H2*60+M2
    print(t2-t1-K)

    
resolve()

Solution (Python):


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

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

Solution (Python):
import sys

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

Solution (Python):

import sys
input = sys.stdin.readline

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

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






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






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




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

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

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

print(main())

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

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

    print(ret)


if __name__ == '__main__':
    main()

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

H1 *= 60
H2 *= 60

T1 = H1 + M1
T2 = H2 + M2

print(T2 - T1 - 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())

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

print(alltime-K)

Solution (Python):
h,m,hh,mm,k=list(map(int,input().split()))

hm=h*60+m
hhmm=hh*60+mm

ans=hhmm-k-hm
print(ans)

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

	print(mins-k)


if __name__ == '__main__':
	main()

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

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

s -= k

print(s)

Solution (Python):
import sys
import math

sys.setrecursionlimit(1000000)


def solve(H1, M1, H2, M2, K):
    S = H1 * 60 + M1
    E = H2 * 60 + M2
    return max(0, E-S-K)


if __name__ == "__main__":
    H1, M1, H2, M2, K = tuple(map(int, input().split(" ")))
    print(solve(H1, M1, H2, M2, K))

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

Solution (Python):


A, B, C, D, K = map(int, input().split())



t = C - A
y = D - B
d = t*60 + y
ans = d - K
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):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d, e = list(map(int, readline().split()))

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

    print(z-e)


if __name__ == '__main__':
    main()

Solution (Python):


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

a = h2 - h
b = m2 - m

minu = a * 60 + b

print(minu - k)

Solution (Python):
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

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

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

print(x2-x1-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())

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

dif = m2 - m1

print(max(0, dif - 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())

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

print(ans)

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

hour=h2-h1
minu=m2-m1

sum=hour*60+minu

print(sum-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

ans = t2 - t1 - k
print(ans)

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

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

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

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

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

Solution (Python):

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

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

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

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

    print(ans)

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

print(t2-t1-K)

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

Solution (Python):
mod = 1000000007
eps = 10**-9


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

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

Solution (Python):




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

print(h-k)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d, k = map(int, readline().split())

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

print(y - x - k)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,m,H,M,k = LI()
    t = 60*(H-h)+M-m
    print(max(0,t-k))
    return


if __name__ == "__main__":
    solve()

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

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

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

Solution (Python):

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

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


print(res)

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(i) for i in input().split()]

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

h,m,hh,mm,K=map(int,input().split())
t=h*60+m
tt=hh*60+mm
print(max(tt-t-K,0))

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

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h1,m1,h2,m2,k = readInts()
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)
print(t - K)

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

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

print(t2-t1-k)

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

h1, m1, h2, m2, k = MAP()
strt = h1 * 60 + m1
end = h2 * 60 + m2
print(end - strt - k)

Solution (Python):
import sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    start = h1 * 60 + m1
    end = h2 * 60 + m2
    print(end - start - k)
resolve()

Solution (Python):
"""
じょえチャンネルおもしろいよ～～～
https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
"""

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