peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
L = list()
for _ in range(N):
    A, B = map(int, input().split())
    L.append((A, B))
L = sorted(L, key=lambda x: x[0])

if N%2 == 1:
    W = L[N//2]
    print(W[1] - W[0] + 1)
else:
    W = L[N//2 - 1]
    V = L[N//2]
    ans = max(W[1] - W[0] + 1, V[1] - V[0] + 1)
    if W[1] >= V[0]:
        print(2*ans - 1)
    else:
        print(ans + 2)
N = int(input())
X = [tuple(map(int, input().split())) for _ in range(N)]
if N == 2:
    ans = sorted(X, key=lambda x: x[1], reverse=True)[0][1] - sorted(X, key=lambda x: x[0])[0][0] + 1
else:
    ans = sorted(X, key=lambda x: x[1], reverse=True)[N // 2][1] - sorted(X, key=lambda x: x[0])[N // 2][0] + 1
print(ans)
from statistics import median

n = int(input())
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

if n % 2 == 1:
    print(median(b) - median(a) + 1)
else:
    print(int(median(b) - median(a)) * 2 + 1)
import numpy as np

N = int(input())
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_median = np.median(a_list).astype('int')
    b_median = np.median(b_list).astype('int')
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = np.median(a_list).astype('int')
    b_median = np.median(b_list).astype('int')
    print(2*(b_median-a_median+1))
N, *AB = map(int, open(0).read().split())

A, B = sorted(AB[::2]), sorted(AB[1::2])

if N % 2 == 1:
    L = A[N // 2]
    R = B[N // 2]
else:
    L = A[N // 2 - 1]
    R = B[N // 2]

print(R - L + 1)
from statistics import median


def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    ans = int(median(b) - median(a))
    if n % 2 == 0:
        ans *= 2
    ans += 1
    print(ans)


if __name__ == '__main__':
    main()
N = int(input())

A = []
B = []

for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
    
if(N % 2 == 1):
    k = int( (N-1) / 2 )
    print(B[k] - A[k] + 1)
else:
    k = int( N / 2 ) - 1
    print(B[k + 1] - A[k] + 1)
import sys
input = sys.stdin.readline
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]
AB.sort()
ans = 1
if N % 2:
    left = AB[N // 2]
    AB.sort(reverse=True,key=lambda x:x[1])
    right = AB[N // 2]
    if left[1] > right[1]:
        ans += right[1]-left[0]
    else:
        ans += left[1]-left[0]
else:
    left = AB[N//2]
    AB.sort(reverse=True,key=lambda x:x[1])
    right = AB[N // 2]
    ans += left[1]+right[1] - (left[0]+right[0])
print(ans)
inp=int(input())
mylist=[]
for i in range(inp):
    x,r = [int(num) for num in input().split()]
    mylist.append(x)
    mylist.append(r)
mylist.sort()    
mylis=len(mylist)
if len(mylist)%2==1:
    ans=(mylis-1)/2+1
    finalAns=mylist[int(ans-1)]
else:
    ans=(mylis/2)
    ans2=(mylis/2+1)
    finalAns=(mylist[int(ans-1)]+mylist[int(ans2-1)])/2
str=str(finalAns)+" "
if str.endswith('.0 ')==True:
    finalAns=int(finalAns)    
print(finalAns)
import math

N = int(input())
list_A, list_B = list(), list()
for _ in range(N):
    A, B = map(int, input().split())
    list_A.append(A)
    list_B.append(B)

list_A.sort()
list_B.sort()

if N%2==0:
    tmp, tmp1 = N//2-1, N//2
    _min = math.floor((list_A[tmp] + list_A[tmp1]) / 2)
    _max = math.ceil((list_B[tmp] + list_B[tmp1]) / 2)
else:
    tmp = N//2
    _min = math.floor(list_A[tmp])
    _max = math.ceil(list_B[tmp])

print(_max-_min+1)
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N%2!=0:
    n=(N+1)//2
    ans=B[n-1]-A[n-1]+1
else:
    n=N//2
    ans1=(A[n-1]+A[n])/2
    ans2=(B[n-1]+B[n])/2
    ans=(ans2-ans1)*2+1
print(ans)
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

if n%2==0:
    min_sum = x[(n//2)-1][0]+x[(n//2)][0]
    max_sum = x[(n//2)-1][1]+x[(n//2)][1]
    print(int((max_sum-min_sum)/2//0.5)+1)
else:
    tmp = x[n//2]
    print(len(range(tmp[0], tmp[-1]+1)))
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
# print(A,B)
if N % 2 == 0:
    n = N // 2
    # print(B[-n] , A[n-1])
    print((B[-n] - A[n-1] + 1) * (B[-n] - A[n-1]) // 2)
else:
    n = N //2 + 1
    print((B[-n] - A[n-1] + 1))
arr = []
a,b = [],[]
for _ in range(int(input())):
    x,y = list(map(int,input().split()))
    a.append(x)
    b.append(y)
    arr.append([x,y])
arr.sort()
n = len(arr)
if n%2!=0:
    x = n//2
    print(arr[x][1]-arr[x][0]+1)
else:
    x = n//2
    y = x-1
    minn = (arr[x][0]+arr[y][0])/2
    maxx = (arr[x][1]+arr[y][1])/2
    print(minn,maxx)
    ans = (maxx-minn)/0.5
    print(int(ans)+1)
import bisect

n = int(input())

l = []
r = []

for i in range(n):
    a, b = map(int, input().split())
    l.append(a)
    r.append(b)

l.sort()
r.sort(reverse=True)

if n%2 == 1:
    print(r[(n-1)//2]-l[(n-1)//2]+1)
else:
    l1, l2 = l[(n-2)//2], l[(n-2)//2+1]
    r1, r2 = r[(n-2)//2+1], r[(n-2)//2]
    d1, d2 = r1-l1+1, r2-l2+1
    d1, d2 = max(d1, d2), min(d1, d2)
    print(r2-l1+1)
from copy import deepcopy
N = int(input())
ABs = [list(map(int,input().split())) for i in range(N)]
ABs_desc = deepcopy(ABs)

ABs.sort(key=lambda x:(x[0],-x[1]))
ABs_desc.sort(key=lambda x: (-x[1],x[0]))

if N%2:
    A,B = ABs[N//2]
    print(B-A+1)
else:
    A1,B1 = ABs[(N-1)//2]
    A2,B2 = ABs_desc[(N-1)//2]
    print(B1+B2-A1-A2+1)
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i],B[i] = map(int,input().split())
A.sort()
B.sort()
if N % 2 == 0:
    print(B[N//2] - A[N//2] + 2)
else:
    print(B[N//2] - A[N//2] + 1)
N = int(input())
conditions = []

for _ in range(N):
    A,B = list(map(int,input().split()))
    conditions.append([A,B])
    
if N % 2 == 1:
    S,M = conditions[int((N + 1) / 2) - 1]
    print(M - S + 1)
    
if N % 2 == 0:
    S1,M1 = conditions[int(N / 2) - 1]
    S2,M2 = conditions[int(N / 2)]
    
    small = S1 + S2
    big = M1 + M2
    
    print(big - small + 1)
N = int(input())
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
from statistics import median
Am = median(A)
Bm = median(B)
if N%2==1:
    ans = Bm-Am+1
else:
    ans = int((Bm-Am)*2+1)
n = int(input())

ls = []
rs = []
for _ in range(n):
    x, y = map(int, input().split())
    ls.append(x)
    rs.append(y)

if n % 2 == 1:
    print(rs[len(rs)//2] - ls[len(ls)//2] + 1)
else:
    a = (rs[len(rs)//2-1] + rs[len(rs)//2]) / 2
    b = (ls[len(ls)//2-1] + ls[len(ls)//2]) / 2
    print(int((10 * a - 10 * b) / 5 + 1))
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

if n % 2 == 1:
    info = sorted(info)
    l = info[n // 2][0]
    info = sorted(info)[::-1]
    r = info[n // 2][1]
    print(r - l + 1)

else:
    info = sorted(info)
    l, lmax = info[n // 2 - 1]
    info = sorted(info)[::-1]
    rmin, r = info[n // 2 - 1]
    length = []
    for i in range(n):
        length.append(min(r, info[i][1]) - max(l, info[i][0]) + 1)
    length = sorted(length, reverse=True)
    print(length[0] * length[1] - 1)
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
seg = [list(map(int, input().split())) for _ in range(n)]
a = [x[0] for x in seg]
b = [x[1] for x in seg]
a.sort()
b.sort()

if n%2 == 1:
	print(b[n//2] - a[n//2] + 1)
else:
	print(b[n//2] + a[n//2] - b[n//2-1] - a[n//2-1] + 1)
import numpy as np

N = int(input())
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_median = np.median(a_list)
    b_median = np.median(b_list)
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = np.median(a_list)
    b_median = np.median(b_list)
    print(2*(b_median-a_median)+1)
n = int(input())
a,b = [], []
for _ in range(n):
  i = input().split()
  a.append(int(i[0]))
  b.append(int(i[1]))
a.sort()
b.sort()
if n%2:
  l = a[n//2]
  h = b[n//2]
  print(l-h+1)
else :
  l = (a[n//2-1]+a[n//2]) / 2
  h = (b[n//2-1]+b[n//2]) / 2
  print(int((l-h)*2) +1)
def task(n, a, b):
    a.sort()
    b.sort()

    if n % 2 == 0:
        median1 = n // 2
        median2 = n // 2 + 1
        ans1 = a[median1 - 1]
        ans2 = b[median2 - 1]
        print((ans2 - ans1) * 2)
    else:
        median = (n + 1) // 2
        print(b[median - 1] - a[median - 1] + 1)


n = int(input())
a = []
b = []
for i in range(0, n):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)
task(n, a, b)
N = int(input())
A = [0 for _ in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    A[i] = b-a+1

A.sort()
if N%2 == 0:
    print(A[N//2-1]//2+A[N//2])
else:
    print(A[N//2])
def median(array):
    L = len(array)
    if L%2==0:
        return (array[L//2-1]+array[L//2])/2
    else:
        return array[L//2]

from math import ceil, floor

N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

print(ceil(median(B))-floor(median(A))+1)
# Count median
N=int(input())
m=[]
M=[]
for i in range(N):
    x,y=map(int,input().split())
    m.append(x)
    M.append(y)
m.sort()
M.sort()

if N%2!=0:
    mini=m[N//2]
    maxi=M[-N//2]

    print(maxi-mini+1)
else:
    mini=m[N//2-1]
    maxi=M[-N//2-1]
    if maxi>=mini:
        print((maxi-mini)*2+1)
    else:
        print(0)
n = int(input())

ls = []
rs = []
for _ in range(n):
    x, y = map(int, input().split())
    ls.append(x)
    rs.append(y)

if n % 2 == 1:
    print(rs[len(rs)//2] - ls[len(ls)//2] + 1)
else:
    a = (rs[len(rs)//2-1] * 10 + rs[len(rs)//2] * 10) / 2
    b = (ls[len(ls)//2-1] * 10 + ls[len(ls)//2] * 10) / 2
    print(int((a - b) // 5 + 1))
n = int(input())
ab = sorted([list(map(int,input().split())) for i in range(n)])
ab_b = sorted(ab,key=lambda x:x[1])
if n==2:
    x1 = ab_b[-1][1]+ab[0][1]/2
    x2 = ab_b[-1][0]+ab[0][0]/2
    ans = int((x1-x2)*2)
elif n%2==1:
    ans = ab_b[-2][1]-ab[1][0]+1
else:
    x1 = ab_b[-2][1]+ab_b[1][1]/2
    x2 = ab[-2][0]+ab[1][0]/2
    ans = int((x1-x2)*2)
print(ans)
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

A = [i[0] for i in AB]
B = [i[1] for i in AB]
from statistics import median

a_med = median(A)
b_med = median(B)

if N%2==1:
  print(b_med - a_med + 1)
  
else:
  print((b_med - a_med) * 2 + 1)
n = int( input())
A = []
B = []

for i in range( n ):
  a, b = map( int, input().split() )
  A.append( a )
  B.append( b )

A = sorted( A )
B = sorted( B )

if n % 2 == 0:
  i1 = n // 2 - 1
  i2 = n // 2
  print( ( B[ i2 ] - A[ i2 ] ) * ( B[ i1 ] - A[ i1 ] ) )
else:
  i = ( n + 1 ) // 2 - 1
  print( B[ i ] - A[ i ] + 1 )
n = int(input())

abl = [map(int,input().split()) for _ in range(n)]

al = []
bl = []

for a,b in abl:
    al.append(a)
    bl.append(b)

if n % 2 == 0:
    min_a = (al[n//2-1] + al[n//2]) / 2
    max_a = (bl[n//2-1] + bl[n//2]) / 2
else:
    min_a = al[(n-1)//2]
    max_a = bl[(n-1)//2]

if n % 2 == 0:
    print(int((max_a - min_a) * 2 + 1))
else:
    print(max_a - min_a + 1)
n = int(input())
ab =[list(map(int,input().split())) for _ in range(n)]

if n % 2 == 0:
  a = (ab[n//2-1][0] + ab[n//2][0])//2
  b = (ab[n//2-1][1] + ab[n//2][1])//2
  ans = (b-a) / 0.5 +1
else:
  a = ab[(n+1)//2-1][0]
  b = ab[(n+1)//2-1][1]
  ans = (b-a) +1

print(int(ans))
N = int(input())
single = []
answer_set = set()
for i in range(N):
    a, b = map(int, input().split())
    single.append(a)
    single.append(b)

single = sorted(single)
total = sum(single)
answer = 0
if N % 2 == 0:
    for i in range(2 ** (2 * N)):
        bag = []
        for j in range(2 * N):
            if ((i >> j) & 1):
                bag.append(single[j])
        if len(bag) == N:
            answer += 1
    print(int(answer / 2))
else:
    print(single[-2] - single[1] + 1)
from copy import deepcopy
N = int(input())
ABs = [list(map(int,input().split())) for i in range(N)]
ABs_desc = deepcopy(ABs)
ABs.sort() #Aでソート
ABs_desc.sort(reverse=True)
if N%2:
    A1,B1 = ABs[N//2]
    A2,B2 = ABs_desc[N//2]
    if B1 < A2:
        print(B1-A1+1 + B2-A2+1)
    else:
        print(B2-A1+1)
else:
    A1,B1 = ABs[(N-1)//2]
    A2,B2 = ABs_desc[(N-1)//2]
    print(B1+B2-A1-A2+1)
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
left = sum(A)
right = sum(B)
if N%2 == 0:
  print(right-left+1)
else:
  A.sort()
  B.sort()
  print(B[(N-1)//2]-A[(N-1)//2]+1)
N = int(input())
numbers = []
for _ in range(N):
    a, b = map(int, input().split())
    numbers.append(b-a+1)
numbers.sort()  # 左を昇順ソート

if N % 2 == 1:
    print(numbers[N%2])
else:
    print(numbers[N%2]+1)
n = int(input())
al = []
bl = []
for _ in range(n):
    a, b = map(int, input().split()) 
    al.append(a)
    bl.append(b)

al.sort()
bl.sort()


if n%2 == 1:
    print(bl[n//2] - al[n//2] + 1)
else:
    print((bl[n//2] - al[n//2-1])*2 + 1)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
aa = []
bb = []
for _ in range(n):
    a, b = map(int, readline().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort(reverse=True)
if n % 2 == 0:
    print(bb[0] - aa[0] + 1)
else:
    print(bb[1] - aa[1] + 1)
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
from statistics import median
A=[0]*N
B=[0]*N
A.sort()
B.sort()
for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b
if N%2:
    print(B[N//2]-A[N//2]+1)
else:
    a=A[N//2-1]+A[N//2]
    b=B[N//2-1]+B[N//2]
    print(b-a+1)
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

if n%2==0:
    min_sum = (x[(n//2)-1][0]+x[(n//2)][0])/2
    max_sum = (x[(n//2)-1][1]+x[(n//2)][1])/2
    print(int((max_sum-min_sum)//0.5)+1)
else:
    tmp = x[n//2]
    print(tmp[1]-tmp[0]+1)
import statistics
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
check = [0]*N
for i in range(N):
    check[i] = arr[i][1]-arr[i][0]+1
tmp = statistics.median(check)
print(tmp)
a = input().split()
H1 = int(a[0])
M1 = int(a[1])
H2 = int(a[2])
M2 = int(a[3])
K = int(a[4])
time = (H2 * 60 + M2) - K
okiru = 60 * H1 + M1
print(time - okiru)
a,b,c,d,k=map(int,input().split())
print((c-a)*60-b+d-k)
h1,m1,h2,m2,k=map(int,input().split())

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

input_nums=[]

for i in range(5):
    input_nums.append(int(input_str[i]))


diff_hour = input_nums[2] - input_nums[0]
diff_hour_to_min = diff_hour * 60
 
diff_min = input_nums[3] - input_nums[1]

total_wake_min = diff_hour_to_min + diff_min

print(total_wake_min - input_nums[4])
h1,m1,h2,m2,k=map(int,input().split())
print((h2-h1)*60+m2-m1-k)
h1, m1, h2, m2, k=map(int, input().split())
wake_time = (h2-h1)*60 + m2 - m1
result = wake_time - k
print(result)
H1, M1, H2, M2, K = map(int,input().split())

print((H2*60 + M2)-(H1*60+M1)-K)
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    h1, m1, h2, m2, k = IL(int)
    all_time = (h2 * 60 + m2) - (h1 * 60 + m1)
    print(all_time - k)


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

	print(mins-k)


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

res = f*60 + g - a*60 - b
print(res)
h1, m1, h2, m2, k = map(int, input().split())

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

if wake_time > k:
    print(wake_time - k);
else:
    print(0);
h1, m1, h2, m2, k = map(int, input().split())

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

hour = HH - H -1
minute=60+MM-M
time = hour * 60 + minute - K

print(time)
H1, H2, H3, H4, K = map(int, input().split())
up = H1*60 + H2
down = H3*60 + H4
print(down - up - K)
h1, m1, h2, m2, k = map(int, input().split(' '))

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

ti = ni - mo - k
print(ti)
H1,M1,H2,M2,K= list(map(int, input().split()))

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

print(a2-a1-K)
# -*- coding: utf-8 -*-

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

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

hour = e // 60
min = e % 60

a += hour
b += min

if b >= 60:
    a += b // 60
    b %= 60

ans = 0
if b > d:
    c -= 1
    ans += 60 - (b - d)
else:
    ans += (d - b)

if c >= a:
    ans += 60 * (c - a)
else:
    print(0)
    exit()

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

#print(H1, M1, H2, M2, K)

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

if mm2 > mm1:
    mmm = mm2-mm1
else:
    mmm = mm2+24*60 - mm1

if mmm > K:
    print(mmm-K)
else:
    print(0)
h1, m1, h2, m2, k = map(int, input().split())
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

print(t2-t1 - k)
H1,M1,H2,M2,K = list(map(int,input().split()))

min1 = H1*60 + M1
min2 = H2*60 + M2
min = min2 - min1


if min > 0:
  print(min-K)
else:
  print(0)
h1,m1,h2,m2,k = map(int,input().split())

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

print(b-a-k)
h1, m1, h2, m2, k = map(int, input().split())

print((h2 * 60 + m2) - (h1 * 60 + m1) - k)
H_1,M_1,H_2,M_2,K=input().split()
H_1=int(H_1)
M_1=int(M_1)
H_2=int(H_2)
M_2=int(M_2)
K=int(K)
H1=H_1*60+M_1
H2=H_2*60+M_2
answer=H2-H1-K
print(answer)
h1,m1,h2,m2,k = map(int,input().split())
H_min = (h2-h1)*60
M_min = m2-m1
time = H_min + M_min
ans = time - k
print(ans)
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

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

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


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

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

print(m-k)
h1, m1, h2, m2, K = list(map(int, input().split()))

diff = (h2-h1) * 60 + m2-m1
print(diff - K)
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()
h, m, H, M, K = map(int, input().split())

print(H*60 +M - ( h*60 +m  + K ))
a = list(map(int,input().split()))
print(a[2]*60+a[3]-a[0]*60-a[1]-a[4])
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

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

hour=h2-h1
minu=m2-m1

sum=hour*60+minu

print(sum-k)
h1, m1, h2, m2, k = list(map(int, input().split()))
 
s = (h1*60)+m1
e = (h2*60)+m2
 
print(e-s-k)
H1,M1,H2,M2,K = map(int, input().split(' '))

#print(H1,M1,H2,M2,K)

# 開始時刻から終了時刻までの長さを分に変換し、勉強時間を減産する

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

#print("{0}分から{1}分まで勉強する".format(start, end))

goal = end - start - K

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

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

is_up = end_min - start_mins
can_start = is_up - k
print(can_start)
h1,m1,h2,m2,k=map(int,input().split())
print((h2-h1)*60+(m2-m1)-k)
n = 0
H1,M1,H2,M2,K = map(int,input().rstrip().split(" "))
n = (H2 - H1)  * 60 + (M2 - M1)
print(n - K)
[h1,m1,h2,m2,k] = [int(i) for i in input().split()]

print((h2 - h1) * 60 + (m2 - m1) - k)
H1,M1,H2,M2,K=map(int,input().split())
print((H2-H1)*60+(M2-M1)-K)
a,b,c,d,e = map(int,input().split())

print(60*(c-a)+d-b-e)
hw,mw,hs,ms,k=map(int,input().split())
waking=(hs*60+ms)-(hw*60+mw)-k
print(max(0,waking))
h1, m1, h2, m2, k = map(int, input().split())
s = h1 * 60 + m1
e = h2 * 60 + m2
print(e - k - s)
H1,M1,H2,M2,K = map(int,input().split())

print(60*(H2-H1)+M2-M1-K)
h1,m1,h2,m2,K = map(int,input().split())
ans = (60*h2+m2) - (60*h1+m1) -K
print(ans)
import sys

input = sys.stdin.readline


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

    if H1 == H2:
        time = M2 - M1
    else:
        time = (60 - M1) + (H2 - H1 - 1) * 60 + M2

    ans = time - K
    print(ans)


if __name__ == "__main__":
    main()
a,b,c,d,e = map(int,input().split())
kis = a * 60 + b
nel = c * 60 + d
print(nel - e - kis)
h1,m1,h2,m2,k=map(int,input().split())
t=0
if m2>m1:
    t=m2-m1+(h2-h1)*60-k
else:
    t=60+m2-m1+(h2-1-h1)*60-k
print(t)
import math
A, B, C, D, E = map(int, input().split())

hour = (C - A) * 60
min = D - B
cnt = hour + min - E

print(cnt)
a,b,c,d,e = map(int, input().split())
print(c*60+d-a*60-b-e)
#a,b,c=map(int,input().split())
#d=list(map(int,input().split()))
#n=int(input())
#d,x=map(int,input().split())
#a=[int(input()) for i in range(n)]

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

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

print(t2-t1-k)
def main():
    h1, m1, h2, m2, k = map(int, input().split())
    a = h1*60+m1
    b = h2*60+m2
    print(b-a-k)

if __name__ == "__main__":
    main()
h1,m1,h2,m2,k=map(int,input().split())
t1=h1*60+m1
t2=h2*60+m2
print(max(t2-t1-k,0))
H1, M1, H2, M2, K = map(int, input().split())
ans = (H2 - H1)*60 + (M2-M1) - K
print(ans)
a, b, c, d, e = map(int, input().split())
start = a*60 + b
end = c*60 + d

print(end - e - start)
H1, M1, H2, M2, K = map(int, input().split())
print((H2 - H1) * 60 + (M2 -M1) - K)
a,b,c,d,e=map(int,input().split())
num=60*a+b
nnum=60*c+d
print(nnum-num-e if (nnum-num)-e>0 else 0)
h,m,H,M,K=map(int,input().split())
t=h*60+m
T=H*60+M
print(T-t-K)
h1, m1, h2, m2, k = map(int, input().split())

print(60 - m1 + (h2 - h1 - 1) * 60 + m2 - k)
H1, M1, H2, M2, K = map(int, input().split())
diff = 60 * H2 + M2 - (60 * H1 + M1)
print(max(0, diff - K))
inputs = list(map(int, input().split()))

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

study_time = latter - inputs[4] - former

print(study_time)
s = list(map(int,input().split()))

h = 60 * (s[2]-s[0])
m = s[3] - s[1]
k = s[4]
print(h+m-k)
H1, M1, H2, M2, K = map(int,input().split())
T = (H2 - H1)*60 + (M2 - M1) - K
if T <= 0:
  print(0)
else:
  print(T)
h1, m1, h2, m2, k = map(int, input().split())
time1 = h1*60+m1
time2 = h2*60+m2
print(time2-time1-k)
H1, M1, H2, M2, K = map(int, input().split())
m1 = 60*H1 + M1
m2 = 60*H2 + M2
print(m2-m1-K)
import math
h,m,h2,m2,k = map(int,input().split())
all = h2*60+m2 - (h*60+m)
print(all - k)
h1,m1,h2,m2,k=map(int,input().split())
print(60*(h2-h1)+m2-m1-k)
a,b,c,d,e=map(int,input().split())
print(c*60+d-a*60-b-e)
H1,M1,H2,M2,K=map(int,input().split())

up=60*(H2-H1)+(M2-M1)
print(up-K)
h, m, h2, m2, k = map(int, input().split())
print(max(0, (h2*60+m2)-(h*60+m)-k))
h1, m1, h2, m2, k = map(int, input().split())
st = h1*60 + m1
end = h2*60 + m2
print(end-st-k)
def task(h1, m1, h2, m2, k):
    t1 = h1 * 60 + m1
    t2 = h2 * 60 + m2
    t = t2 - t1
    print(max(0, t - k))
    #print(h1, m1, h2, m2, k)


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