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):
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    H1,M1,H2,M2,K = list(map(int,_in[0].split(' ')))  
    
    cnt = max((H2*60+M2)-(H1*60+M1)-K,0)
    
    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque

from bisect import bisect_left, bisect_right









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


if __name__ == '__main__':
    main()

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

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

Solution (Python):

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

h1 = 60*li[0]+li[1]
h2 = 60*li[2]+li[3]
print(h2-h1-li[-1])

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

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

Solution (Python):


LI = lambda: list(map(int, input().split()))


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


def main():
    x = H1 * 60 + M1
    y = H2 * 60 + M2
    ans = y - x - K
    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())
    TIME = (H2 - H1)*60 + (M2 - M1)
    ans = TIME - K
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

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

main()

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

Solution (Python):


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

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

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


main()

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

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

if H1>H2:
    H2+=24

ans=H2*60+M2-(H1*60+M1)
ans-=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())
start = h2 * 60 + m2 - k
time = h1 * 60 + m1
ans = start - time
print(ans)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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

from itertools import permutations
from math import factorial, hypot





H1, M1, H2, M2, K = getNM()
opt1 = H1 * 60 + M1
opt2 = H2 * 60 + M2
print(abs(opt2 - opt1) - K)

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

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

Solution (Python):

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

t1 = h*60 + m
t2 = h2*60 + m2

ret = t2 - t1 - k
print(ret)

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, D, K = map(int, input().split())
    f = A * 60 + B
    s = C * 60 + D
    print(s - f - K)

    return 0

if __name__ == "__main__":
    solve()

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

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

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div

h1, m1, h2, m2, k = ri_()
a1 = h1 * 60 + m1
a2 = h2 * 60 + m2
print(a2 - a1 - k)

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

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

Solution (Python):

ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

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

Solution (Python):
import math

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

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

m2 -= k

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

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

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

print(int(ans))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    h1, m1, h2, m2, k = map(int, input().split())
    wake = (h2 - h1) * 60 + m2 - m1
    print(max(0, wake - 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 = map(int, input().split())
m1 = H1*60+M1
m2 = H2*60+M2
print(m2-m1-K)

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

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


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


if __name__ == '__main__':
    solve()

Solution (Python):
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

h1,m1,h2,m2,k = mp()
hun1 = h1*60+m1
hun2 = h2*60+m2
print(hun2-hun1-k)

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    Hs, Ms, He, Me, K = map(int, readline().split())
    ans = (He-Hs)*60 + (Me-Ms) -K
    print(max(ans,0))
if __name__ == '__main__':
    main()

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

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

ti = ni - mo - k
print(ti)

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

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

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




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

val = 0
val += (h2 - h1) * 60
val += m2 - m1

print(val - k)

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

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

if T2-T1>=K:
    print(T2-T1-K)
else:
    print(0)

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

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

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

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

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

a=LIST()
if a[1]<=a[3]:
    print((a[2]-a[0])*60+(a[3]-a[1])-a[-1])
else:
    print((a[2]-a[0]-1)*60+(a[3]-a[1]+60)-a[-1])

Solution (Python):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


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

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

term = sleep - wake

print(term-K)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    h1,m1,h2,m2,k=map(int, input().split())
    x=h1*60+m1
    y=h2*60+m2
    print(y-x-k)
resolve()

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

Solution (Python):


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

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

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

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

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

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

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

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    H1, M1, H2, M2, K = Scanner.map_int()
    ans = (H2 - H1) * 60
    ans += (M2 - M1)
    ans = max(0, ans - K)
    print(ans)


def main():
    
    
    solve()


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

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

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

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


def read():
    H1, M1, H2, M2, K = map(int, input().strip().split())
    return H1, M1, H2, M2, K


def solve(H1, M1, H2, M2, K):
    m1 = H1 * 60 + M1
    m2 = H2 * 60 + M2
    return m2 - m1 - K


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
l = [int(x) for x in input().split()]
nagasa = 60*l[2] + l[3] - 60*l[0] - l[1]
print(nagasa-l[4])

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())
run = (H2 - H1) * 60 + (M2 - M1)
print(run - 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())
a = h1*60+m1
b = h2*60+m2
print(b-a-k)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

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

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

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

Solution (Python):
def main():

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

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

    if b-a < K:
        return 0
    return b-a-K


if __name__ == '__main__':
    print(main())

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

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    h1, m1, h2, m2, k = mi()
    print((h2-h1)*60+(m2-m1) - k)



if __name__ == "__main__":
    main()

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


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



if __name__ == '__main__':
    main()

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

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

ans = time - K

print(max(ans, 0))

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

Solution (Python):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


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




main()

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

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

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

print(smin-K)

Solution (Python):
HA,MA,HB,MB,K=map(int,input().split())

result=60*HB+MB-(60*HA+MA)-K

print(result)

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

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

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

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

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

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

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

a=e-s

print(a-k)

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

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

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

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

print(ans)

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

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

ans = max(0, B - A - K)

print (ans)

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


h = H2- H1
m = M2 - M1

time = h*60 + m


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

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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 = 60 * H2 + M2 - 60 * H1 - M1

print(a-K)

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

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

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):
def main():

    h,m,h1,m1,k = tuple([int(t)for t in input().split()])

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

if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
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 [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  return max(0,a-k)


print(main())

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

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

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

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
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

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

Solution (Python):
H1, M1, H2, M2, K = [int(x) for x in 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())

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

print(ans)

Solution (Python):
def main():
    h1, m1, h2, m2, k = map(int, input().split())
    time = (h2 - h1) * 60 - m1 + m2
    print(max(time - k, 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):
H1, M1, H2, M2, K = map(int, input().split())
H = H2-H1
M = M2-M1
print(H*60+M-K)

Solution (Python):
def examA():
    H1, M1, H2, M2, K = LI()
    T = (H2-H1)*60 + (M2-M1)
    ans = T-K
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
if __name__ == '__main__':
    from sys import stdin
    
    
    
    
    
    
    input = stdin.readline

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

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

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

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

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

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

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H1, M1, H2, M2, K):
    d = (H2-H1) * 60
    d += (M2-M1)
    return d - K


def main():
    H1, M1, H2, M2, K = read_int_n()
    print(slv(H1, M1, H2, M2, K))


if __name__ == '__main__':
    main()

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

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

h = (A[2]-A[0])*60+A[3]-A[1]-A[4]
print(h)

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

H = H2 - H1
M = M2 - M1

print(max(0, H * 60 + M - K))

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

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

print(a)

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

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

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

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

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

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

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

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

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

ans = max(t2 - k - t1, 0)
print(ans)

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

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

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

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

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

Solution (Python):
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    h1, m1, h2, m2, k = mput()
    hoge = h1*60+m1
    huga = h2*60+m2-k
    piyo = huga - hoge
    print(piyo)
    return 0

if __name__ == "__main__":
    solve()

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

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

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

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

print(m)

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

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

Solution (Python):
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq

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



a = h2 - h1
b = m2 - m1

print(60 * a + b - k)

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