Karen is getting ready for a new school day!

 [Image] 

It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.

What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?

Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.


-----Input-----

The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).


-----Output-----

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.


-----Examples-----
Input
05:39

Output
11

Input
13:31

Output
0

Input
23:59

Output
1



-----Note-----

In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.

In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.

In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.

Difficulty: EASY
Tags: Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
(a, b) = input().split(':')
min = 0
a_rev = a[::-1]
while int(a_rev) < int(b) or int(a_rev) >= 60:
	min += 60 - int(b)
	b = 0
	a = '{0:02}'.format((int(a) + 1) % 24)
	a_rev = a[::-1]
min += int(int(a_rev) - int(b))
print(min)


def checkpal(h, m):
	if h < 10:
		if m == h * 10:
			return True
		else:
			return False
	else:
		temp = h % 10
		h //= 10
		if m == temp * 10 + h:
			return True
		else:
			return False
tm = input()
hour = int(tm[0]) * 10 + int(tm[1])
minute = int(tm[3]) * 10 + int(tm[4])
ans = 0
i = hour
j = minute
while not checkpal(i, j):
	if j == 59:
		j = 0
		if i == 23:
			i = 0
		else:
			i += 1
	else:
		j += 1
	ans += 1
print(ans)


(h, m) = map(int, input().split(':'))
count = 0
while h % 10 != m // 10 or h // 10 != m % 10:
	m += 1
	count += 1
	if m == 60:
		h += 1
		h %= 24
		m = 0
print(count)


arr = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412, 1440]
(hh, mm) = map(int, input().split(':'))
mins = hh * 60 + mm
res = 3600
for pali in arr:
	if pali >= mins and pali - mins < res:
		res = pali - mins
print(res)


s = input()
i = 0
while s[:2] != s[:2:-1]:
	a = int(s[:2])
	b = int(s[3:])
	if b == 59:
		a += 1
		b = 0
	else:
		b += 1
	if a == 24:
		a = 0
	if a < 10:
		c = '0' + str(a)
	else:
		c = str(a)
	if b < 10:
		d = '0' + str(b)
	else:
		d = str(b)
	s = c + ':' + d
	i += 1
print(i)


s = input().strip()
s2 = s
h = 5
ans = 0
while s != s[-1::-1]:
	ans += 1
	h = int(s[:2])
	m = int(s[3:])
	if m == 59:
		h += 1
		m = 0
	else:
		m += 1
	if h == 24:
		h = 0
	if h < 10:
		s = '0' + str(h) + ':'
	else:
		s = str(h) + ':'
	if m < 10:
		s += '0' + str(m)
	else:
		s += str(m)
	s.strip()
print(ans)


(hh, mm) = input().split(':')
(h, m) = map(int, (hh, mm))
t1 = 60 * h + m
if hh[1] < '6' and mm > hh[::-1]:
	h += 1
if h % 10 > 5:
	h = (h // 10 + 1) * 10
t2 = 60 * h + int(str(h % 24).zfill(2)[::-1])
print(t2 - t1)


def pal(x):
	s = x % 10
	s *= 10
	s += x // 10
	return s
(h, m) = map(int, input().split(':'))
pal_h = pal(h)
minutes = 0
if pal_h >= m and pal_h < 60:
	x = 0
else:
	while True:
		h += 1
		minutes += 60
		h %= 24
		pal_h = pal(h)
		if pal_h < 60:
			break
minutes += pal_h - m
print(minutes)


def incr(s):
	(x, y) = map(int, s.split(':'))
	y += 1
	if y == 60:
		y = 0
		x += 1
		x %= 24
	return f'{x:02}:{y:02}'
x = input()
t = 0
while x != x[::-1]:
	x = incr(x)
	t += 1
print(t)


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())

def incmm(hh, mm):
	hhi = int(hh)
	mmi = int(mm)
	if mmi == 59:
		if hhi == 23:
			hhi = 0
		else:
			hhi += 1
		mmi = 0
	else:
		mmi += 1
	hh = str(hhi)
	mm = str(mmi)
	if len(hh) == 1:
		hh = '0' + hh
	if len(mm) == 1:
		mm = '0' + mm
	return (hh, mm)
(hh, mm) = input().split(':')
i = 0
while True:
	tt = hh + mm
	if tt == tt[::-1]:
		print(i)
		exit()
	(hh, mm) = incmm(hh, mm)
	i += 1


def to_string(n):
	s = str(n)
	if n < 10:
		s = '0' + s
	return s
(s1, s2) = map(int, input().split(':'))
res = 0
while to_string(s1) != to_string(s2)[::-1]:
	res += 1
	s2 += 1
	if s2 == 60:
		s2 = 0
		s1 += 1
	if s1 == 24:
		s1 = 0
print(res)


import sys
time = sys.stdin.readline()
stringminutes = time[3] + time[4]
minutes = int(stringminutes)
hours = time[0] + time[1]
hrsToMin = int(hours)
hrminutes = hrsToMin * 60
timeOfDay = hrminutes + minutes
if 351 <= timeOfDay <= 600:
	print(601 - timeOfDay)
elif 951 < timeOfDay <= 1202:
	print(1202 - timeOfDay)
elif 0 <= timeOfDay < 351:
	multipleOf70 = 0
	while timeOfDay > multipleOf70:
		multipleOf70 = multipleOf70 + 70
	print(multipleOf70 - timeOfDay)
elif 601 <= timeOfDay <= 951:
	multipleOf70 = 601
	while timeOfDay > multipleOf70:
		multipleOf70 = multipleOf70 + 70
	print(multipleOf70 - timeOfDay)
elif 1202 <= timeOfDay <= 1412:
	multipleOf70 = 1202
	while timeOfDay > multipleOf70:
		multipleOf70 = multipleOf70 + 70
	print(multipleOf70 - timeOfDay)
elif 1412 < timeOfDay < 1440:
	print(1440 - timeOfDay)


min_t = 601
s = input()
h1 = s[0]
h2 = s[1]
h = int(h1) * 10 + int(h2)
m1 = s[3]
m2 = s[4]
m = int(m1) * 10 + int(m2)
if h == 0:
	if m > 0:
		print(70 - m)
	else:
		print(0)
elif h <= 5 and m <= 50:
	hp = h1 + h2
	hp = hp[::-1]
	hp = int(hp[0]) * 10 + int(hp[1])
	if hp >= m:
		print(hp - m)
	else:
		hp1 = hp + 10
		print(hp1 + 60 - m)
elif h < 10:
	print(601 - (h * 60 + m))
elif h <= 15 and m <= 51:
	hp = h1 + h2
	hp = hp[::-1]
	hp = int(hp[0]) * 10 + int(hp[1])
	if hp >= m:
		print(hp - m)
	else:
		hp1 = hp + 10
		print(hp1 + 60 - m)
elif h < 20:
	print(20 * 60 + 2 - (h * 60 + m))
elif h < 23:
	hp = h1 + h2
	hp = hp[::-1]
	hp = int(hp[0]) * 10 + int(hp[1])
	if hp >= m:
		print(hp - m)
	else:
		hp1 = hp + 10
		print(hp1 + 60 - m)
elif m <= 32:
	print(32 - m)
else:
	print(60 - m)


def minutes(time):
	return int(time[:2]) * 60 + int(time[3:])

def zeroes(x):
	sx = str(x)
	if len(sx) == 1:
		sx = '0' + sx
	return sx

def format(minutes):
	hours = minutes // 60
	minutes = minutes % 60
	return zeroes(hours) + ':' + zeroes(minutes)

def palindrome(x):
	return x == x[::-1]
s = minutes(input())
for i in range(24 * 60):
	if palindrome(format((s + i) % (24 * 60))):
		print(i)
		break


import time

def calcular_min(hora):
	(h, m) = hora.split(':')
	l_pal = []
	h_tmp = 0
	m_tmp = 0
	hora_tmp = hora
	hora_ant = ''
	cont = 0
	l_h = []
	l_m = []
	while True:
		hora_ant = hora_tmp
		l_pal = list(hora_tmp)
		l_pal.reverse()
		hora_tmp = ''.join(l_pal)
		if hora_ant == hora_tmp:
			return cont
		elif int(m) == 59:
			m = '00'
			cont += 1
			if int(h) == 23:
				h = '00'
			else:
				h_tmp = int(h) + 1
				h = str(h_tmp)
		else:
			m_tmp = int(m) + 1
			m = str(m_tmp)
			cont += 1
		l_h = list(h)
		l_m = list(m)
		if len(l_h) < 2:
			l_h.insert(0, '0')
		if len(l_m) < 2:
			l_m.insert(0, '0')
		hora_tmp = ':'.join([''.join(l_h), ''.join(l_m)])
hora = input()
print(calcular_min(hora))


inp = list(map(int, input().split(':')))
(h, m) = inp
palindromes = [[0, 0], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [10, 1], [11, 11], [12, 21], [13, 31], [14, 41], [15, 51], [20, 2], [21, 12], [22, 22], [23, 32], [24, 0]]
for time in palindromes:
	if h == time[0] and m <= time[1]:
		break
	if h < time[0]:
		break
print((time[0] - h) * 60 + time[1] - m)


n = input().split(':')
l = n[0]
s = str(n[0]) + str(n[1])
b = 0
if s == s[::-1]:
	print(0)
elif n[0] == '23' and n[1] > '32':
	print(60 - int(n[1]))
else:
	v = str(n[0])[::-1]
	if int(v) < 60 and int(v) > int(n[1]):
		print(int(v) - int(n[1]))
	else:
		while True:
			n[0] = int(n[0]) + 1
			if len(str(n[0])) == 1:
				n[0] = '0' + str(n[0])
			z = str(n[0])[::-1]
			if int(z) < 60:
				b = int(n[0]) - int(l)
				m = b * 60 - int(n[1])
				print(m + int(z))
				break


(h, m) = input().split(':')
k = h + m
a = int(h)
b = int(m)
cnt = 0
while k != k[-1::-1]:
	if a == 23 and b == 59:
		k = '0000'
		cnt += 1
	else:
		if b == 59:
			a += 1
			b = 0
		else:
			b += 1
		if a < 10:
			if b < 10:
				k = '0' + str(a) + '0' + str(b)
			else:
				k = '0' + str(a) + str(b)
		elif b < 10:
			k = str(a) + '0' + str(b)
		else:
			k = str(a) + str(b)
		cnt += 1
print(cnt)


s = input()
h = s[0:2]
m = s[3:]
answer = 0
while str(h) + str(m) != str(m[1]) + str(m[0]) + str(h[1]) + str(h[0]):
	answer += 1
	m = str(int(m) + 1)
	if int(m) == 60:
		m = '00'
		h = str(int(h) + 1)
		if int(h) == 24:
			h = '00'
		if len(h) != 2:
			h = '0' + h
	if len(m) != 2:
		m = '0' + m
print(answer)


(h, m) = (int(x) for x in input().split(':'))
a = 0
while h // 10 != m % 10 or h % 10 != m // 10:
	a += 1
	m += 1
	if m == 60:
		h = h + 1
		m = 0
	if h == 24:
		h = 0
print(a)


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

def get_string(number):
	if number < 10:
		return '0' + str(number)
	return str(number)
(hours, minutes) = input().split(':')
ans = 0
while hours != minutes[::-1]:
	ans += 1
	minutes = int(minutes) + 1
	hours = int(hours)
	if minutes > 59:
		hours += 1
		minutes = 0
	if hours > 23:
		hours = 0
	minutes = get_string(minutes)
	hours = get_string(hours)
print(ans)


import sys
time = input()
pal = time[::-1]
a = int(time[0:2])
c = int(pal[0:2])
b = int(time[3:])
d = int(pal[3:])
if time == pal:
	print(0)
elif d > b and d <= 59:
	print(d - b)
elif a == 23:
	print(abs(60 - b))
elif 5 <= a <= 9:
	print((9 - a) * 60 + (61 - b))
elif 15 <= a <= 19:
	print((19 - a) * 60 + (60 - b + 2))
else:
	f = int(str(a + 1)[::-1])
	if f // 10 == 0:
		f *= 10
	print(60 - b + f)


(HH, MM) = input().split(':')
if int(HH) <= 4 and int(HH) >= 0 or (int(HH) >= 20 and int(HH) <= 22) or (int(HH) >= 10 and int(HH) <= 14):
	if int(MM) <= int(''.join(list(reversed(HH)))):
		print(int(''.join(list(reversed(HH)))) - int(MM))
	else:
		z = str(int(HH) + 1).zfill(2)
		print(60 - (int(MM) - int(''.join(reversed(z)))))
elif int(HH) == 5 or int(HH) == 15:
	if int(MM) <= int(''.join(list(reversed(HH)))):
		print(int(''.join(list(reversed(HH)))) - int(MM))
	else:
		z = str(int(HH) + 5).zfill(2)
		print(300 - (int(MM) - int(''.join(reversed(z)))))
elif int(HH) == 23:
	if int(MM) <= int(''.join(list(reversed(HH)))):
		print(int(''.join(list(reversed(HH)))) - int(MM))
	else:
		print(60 - int(MM))
else:
	y = (int(int(HH) / 10) + 1) * 10
	print((y - int(HH)) * 60 - int(MM) + int(''.join(list(reversed(str(y))))))


def tick(hh, mm):
	while True:
		yield (hh, mm)
		mm += 1
		if mm == 60:
			mm = 0
			hh += 1
		if hh == 24:
			hh = 0

def is_palindrome(hh, mm):
	mms = str(mm)
	if mm < 10:
		mms = '0' + mms
	hhs = str(hh)
	if hh < 10:
		hhs = '0' + hhs
	return hhs[::-1] == mms
(hh, mm) = map(int, input().split(':'))
counter = 0
for (hh, mm) in tick(hh, mm):
	if is_palindrome(hh, mm):
		print(counter)
		break
	counter += 1


input = input().split(':')
if input[0][0:1] == '0':
	input[0] = input[0][1:]
if input[1][0:1] == '0':
	input[1] = input[1][1:]
h = eval(input[0])
m = eval(input[1])
count = 0
from math import floor
while floor(h / 10) != m % 10 or floor(m / 10) != h % 10:
	m += 1
	count += 1
	if m == 60:
		h += 1
		m = 0
	if h == 24:
		h = 0
print(count)


l = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412]
s = input().split(':')
t = int(s[0]) * 60 + int(s[1])
if t > 1412:
	print(1440 - t)
else:
	for i in range(0, len(l)):
		if l[i] >= t:
			print(l[i] - t)
			break


import sys
s = input()
if s == '23:59':
	n = 1
	print(1)
	sys.exit()
m = s[::-1]
n = 0
if s != m:
	n1 = int(s[0:2][::-1])
	n2 = int(s[3:5])
	if n2 > n1 or n1 >= 60:
		if n1 == 32:
			n = 60 - n2
			print(n)
			sys.exit()
		n1 = int(str(int(s[0:2]) + 1)[::-1])
		if int((int(s[0:2]) + 1) / 10) == 0:
			n1 = n1 * 10
		if n1 >= 60 and n1 < 100:
			n = (10 - int(n1 / 10)) * 60 + 60 - n2 + 1 + n1 % 10
			print(n)
			sys.exit()
		n = 60 - n2 + n1
		print(n)
		sys.exit()
	if n1 > n2:
		n = n1 - n2
print(n)


hours = input()
ans = 0
if hours[0] != '0':
	hours1 = str(hours[0]) + str(hours[1])
	pref = ''
if hours[3] != '0':
	minutes1 = str(hours[3]) + str(hours[4])
	pref1 = ''
if hours[0] == '0':
	hours1 = str(hours[1])
	pref = '0'
if hours[3] == '0':
	minutes1 = hours[4]
	pref1 = '0'
minutes2 = list(str(minutes1))
minutes2.reverse()
minutes2 = ''.join(minutes2)
while str(pref) + str(hours1) != str(minutes2) + str(pref1):
	ans += 1
	minutes1 = int(minutes1)
	minutes1 += 1
	if minutes1 >= 60:
		hours1 = int(hours1)
		hours1 += 1
		minutes1 = '0'
	hours1 = int(hours1)
	if hours1 >= 24:
		hours1 = 0
	if len(str(minutes1)) == 1:
		pref1 = '0'
	if len(str(hours1)) == 1:
		pref = '0'
	if len(str(minutes1)) == 2:
		pref1 = ''
	if len(str(hours1)) == 2:
		pref = ''
	minutes2 = list(str(minutes1))
	minutes2.reverse()
	minutes2 = ''.join(minutes2)
print(ans)


def is_parindrome(h, m):
	s = '{:02d}:{:02d}'.format(h, m)
	return s == s[::-1]

def main():
	(h, m) = list(map(int, input().split(':')))
	c = 0
	while not is_parindrome(h, m):
		m += 1
		c += 1
		if m == 60:
			h += 1
			m = 0
			if h == 24:
				h = 0
	return c
print(main())


time = input()
numbers = time.split(':')
hour = int(numbers[0])
minute = int(numbers[1])
total = hour * 60 + minute
minutes = 0
results = 'no'
while results != 'yes':
	hour = str(int(total / 60) % 24)
	minute = str(total % 60)
	if len(hour) == 1:
		hour = '0' + hour
	if len(minute) == 1:
		minute = '0' + minute
	time = hour + minute
	if time[::-1] == time:
		results = 'yes'
		break
	minutes += 1
	total += 1
print(minutes)


def main():
	read = lambda : tuple(map(int, input().split()))

	def to2(v):
		s = str(v)
		if v < 10:
			return '0' + s
		return s

	def isPal(h, m):
		if h == 24:
			h = 0
		s1 = to2(h) + to2(m)
		return s1 == s1[::-1]
	(h, m) = map(int, input().split(':'))
	t = h * 60 + m
	t1 = t
	k = 0
	while not isPal(t1 // 60, t1 % 60):
		t1 += 1
	print(t1 - t)
main()


(h, m) = [int(i) for i in input().strip().split(':')]
t = h * 60 + m
for i in range(1440):
	a = str(t // 60)
	b = str(t % 60)
	if len(a) == 1:
		a = '0' + a
	if len(b) == 1:
		b = '0' + b
	c = b[1] + b[0]
	if a == c:
		print(i)
		exit(0)
	t = (t + 1) % 1440


a = input().split(':')
i = 0
while a[0] != a[1][::-1]:
	i += 1
	a[1] = str(int(a[1]) + 1)
	if a[1] == '60':
		a[1] = '00'
		a[0] = str((int(a[0]) + 1) % 24)
	a[0] = ('0' if len(a[0]) == 1 else '') + a[0]
	a[1] = ('0' if len(a[1]) == 1 else '') + a[1]
print(i)


n = input()
if n == n[::-1]:
	print(0)
	exit(0)
hh = n[:2]
mm = n[3:]
h = int(hh)
m = int(mm)
if int(hh[::-1]) > m and int(hh[::-1]) < 60:
	ans = int(hh[::-1]) - m
else:
	h += 1
	if h == 24:
		h = 0
	if len(str(h)) == 1:
		hh = '0' + str(h)
	else:
		hh = str(h)
	c = 0
	while int(hh[::-1]) >= 60:
		h += 1
		c += 1
		if len(str(h)) == 1:
			hh = '0' + str(h)
		else:
			hh = str(h)
	ans = c * 60 + 60 - m + int(hh[::-1])
print(ans)


def func(h, m):
	h1 = int(h)
	m1 = int(m)
	if h1 == 0:
		if m1 > 0:
			return 70 - m1
		else:
			return 0
	elif h1 > 0 and h1 < 5:
		x = int(''.join(reversed(list(h))))
		y = int(''.join(reversed(list(h)))) + 10
		if m1 <= x:
			return x - m1
		else:
			return (h1 + 1) * 60 + y - (h1 * 60 + m1)
	elif h1 == 5:
		if m1 <= 50:
			return 50 - m1
		else:
			return 10 * 60 + 1 - (5 * 60 + m1)
	elif h1 >= 6 and h1 <= 9:
		return 10 * 60 + 1 - (h1 * 60 + m1)
	elif h1 >= 10 and h1 < 15:
		x = int(''.join(reversed(list(h))))
		y = int(''.join(reversed(list(str(h1 + 1)))))
		if m1 <= x:
			return x - m1
		else:
			return (h1 + 1) * 60 + y - (h1 * 60 + m1)
	elif h1 == 15:
		if m1 <= 51:
			return 51 - m1
		else:
			return 20 * 60 + 2 - (15 * 60 + m1)
	elif h1 >= 16 and h1 <= 19:
		return 20 * 60 + 2 - (h1 * 60 + m1)
	elif h1 >= 20 and h1 < 23:
		x = int(''.join(reversed(list(h))))
		y = int(''.join(reversed(list(str(h1 + 1)))))
		if m1 <= x:
			return x - m1
		else:
			return (h1 + 1) * 60 + y - (h1 * 60 + m1)
	elif h1 == 23:
		x = int(''.join(reversed(list(h))))
		if m1 <= x:
			return x - m1
		else:
			return 24 * 60 - (h1 * 60 + m1)
t1 = input()
x = t1.index(':')
h1 = t1[0:x]
m1 = t1[x + 1:]
s1 = int(h1) * 60 + int(m1)
print(func(h1, m1))


s = input().split(':')
a = s[0]
b = s[1]
p = 0
while True:
	if a == b[::-1]:
		print(p)
		quit()
	p += 1
	k = int(b)
	if k < 59:
		k += 1
		if k > 9:
			b = str(k)
		else:
			b = '0' + str(k)
	else:
		b = '00'
		w = int(a)
		if w < 23:
			w += 1
			if w > 9:
				a = str(w)
			else:
				a = '0' + str(w)
		else:
			a = '00'


hs = []
ms = []
for i in range(24):
	hh = str(i)
	if i < 10:
		hh = '0' + str(i)
	mm = hh[1] + hh[0]
	if int(mm) < 60:
		hs.append(hh)
		ms.append(mm)
(hh, mm) = input().split(':')
if hh == '23' and int(mm) > 32:
	print(60 - int(mm))
else:
	for i in range(len(hs)):
		if int(hs[i]) >= int(hh):
			if int(hs[i]) > int(hh):
				mins = 60 * (int(hs[i]) - int(hh))
				if int(mm) > int(ms[i]):
					mins -= int(mm) - int(ms[i])
				elif int(mm) < int(ms[i]):
					mins += int(ms[i]) - int(mm)
				print(mins)
				break
			elif int(ms[i]) > int(mm):
				print(int(ms[i]) - int(mm))
				break
			elif int(ms[i]) == int(mm):
				print(0)
				break


time = input().split(':')
(h, m) = (time[0], time[1])
count = 0

def check_palindrome(h, m):
	if m[::-1].zfill(2) == h.zfill(2):
		return True
while 1:
	while int(m) < 60:
		(h, m) = (str(h), str(m))
		ans = check_palindrome(h.zfill(2), m.zfill(2))
		if ans:
			print(count)
			exit()
		count += 1
		a = int(m)
		m = a + 1
		while int(m) >= 60:
			(h, m) = (str(h), str(m))
			add_h = int(m) // 60
			a = int(h)
			h = a + add_h
			while int(h) > 23:
				a = int(h)
				h = a % 24
			m = int(m) % 60
			(h, m) = (str(h), str(m))
			ans = check_palindrome(h.zfill(2), m.zfill(2))
			if ans:
				print(count)
				exit()
			a = int(m)
			m = a + 1
			count += 1
	break


(h, m) = map(int, input().split(':'))

def ispalindrome(hh, mm):
	if len(hh) == 1:
		hh = '0' + hh
	if len(mm) == 1:
		mm = '0' + mm
	s = hh + mm
	return s[0] == s[-1] and s[1] == s[-2]
cant = 0
while True:
	if ispalindrome(str(h), str(m)):
		print(cant)
		exit()
	m += 1
	if m >= 60:
		h += 1
		m = 0
		h %= 24
	cant += 1


(hours, minutes) = input().split(':')
(hours, minutes) = (int(hours), int(minutes))
count = 0

def is_pal(string):
	return string == string[::-1]

def get_time(hours, minutes):
	s = ''
	if hours < 10:
		s += '0'
	s += str(hours)
	if minutes < 10:
		s += '0'
	s += str(minutes)
	return s
while not is_pal(get_time(hours, minutes)):
	minutes += 1
	if minutes == 60:
		minutes = 0
		hours += 1
	if hours == 24:
		hours = 0
	count += 1
print(count)


def pad(z):
	if z < 10:
		return '0' + str(z)
	else:
		return str(z)
(h, m) = [int(i) for i in input().split(':')]
s = pad(h) + pad(m)
if s == s[::-1]:
	print(0)
else:
	for i in range(1, 2000):
		m += 1
		if m == 60:
			h += 1
			if h == 24:
				h = 0
			m = 0
		s = pad(h) + pad(m)
		if s == s[::-1]:
			print(i)
			break


s = input()
h = int(s[0:2])
m = int(s[3:5])
abs_time = h * 60 + m
palins = []
for i in range(0, 351, 70):
	palins.append(i)
for i in range(601, 70 * 5 + 601 + 1, 70):
	palins.append(i)
for i in range(1202, 70 * 4 + 1202, 70):
	palins.append(i)
palins.append(1440)
for i in range(len(palins)):
	if abs_time <= palins[i]:
		print(palins[i] - abs_time)
		break


def palindrom(h, m):
	h1 = h // 10
	h2 = h % 10
	m1 = m // 10
	m2 = m % 10
	return h1 == m2 and h2 == m1
x = input()
h = int(x[:2])
m = int(x[3:])
zlicz = 0
while not palindrom(h, m):
	m += 1
	zlicz += 1
	if m == 60:
		h += 1
		m = 0
		if h == 24:
			h = 0
print(zlicz)


def check(h, m):
	s1 = chr(h % 10 + 48)
	h //= 10
	s1 += chr(h % 10 + 48)
	s1 = s1[::-1]
	s2 = chr(m % 10 + 48)
	m //= 10
	s2 += chr(m % 10 + 48)
	s2 = s2[::-1]
	if s1[0] == s2[1] and s1[1] == s2[0]:
		return True
	else:
		return False
(h, m) = map(int, input().split(':'))
ans = 0
while True:
	if check(h, m) == True:
		break
	else:
		ans += 1
		m += 1
		if m == 60:
			h += 1
			m = 0
		if h == 24:
			h = 0
print(ans)


from datetime import datetime
a = ['00', '01', '02', '03', '04', '05', '10', '11', '12', '13', '14', '15', '20', '21', '22', '23', '24']
b = [0, 10, 20, 30, 40, 50, 1, 11, 21, 31, 41, 51, 2, 12, 22, 32, 0]
s = input().split(':')
ans = 0
h = s[0]
m = s[1]
if h in a:
	i = a.index(h)
	if b[i] - int(m) >= 0:
		ans = b[i] - int(m)
	else:
		ans = b[i + 1] + 60 - int(m) + (int(a[i + 1]) - int(h) - 1) * 60
else:
	while h not in a:
		t = int(h) + 1
		h = str(t)
		if t < 10:
			h = '0' + h
	s1 = s[0] + ':' + s[1] + ':00'
	s2 = h + ':' + str(b[a.index(h)]) + ':00'
	FMT = '%H:%M:%S'
	ans = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
	ans = str(ans).split(':')
	ans = int(ans[0]) * 60 + int(ans[1])
print(ans)


(a, b) = map(int, input().split(':'))
c = 0
while 1:
	if a < 10:
		y = '0' + str(a)
	else:
		y = str(a)
	if b < 10:
		x = '0' + str(b)
	else:
		x = str(b)
	if x[::-1] == y:
		print(c)
		exit()
	b += 1
	c += 1
	if b == 60:
		b = 0
		a += 1
	if a == 24:
		a = 0


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
import statistics
from statistics import mode
from functools import reduce
mod = 1000000007

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def most_frequent(List):
	occurence_count = Counter(List)
	return occurence_count.most_common(1)[0][0]

def most_common(List):
	return mode(List)

def chinese_remainder(a, p):
	prod = reduce(op.mul, p, 1)
	x = [prod // pi for pi in p]
	return sum((a[i] * pow(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a)))) % prod

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3

def memoized(*args):
	if args in stored_results:
		return stored_results[args]
	else:
		result = stored_results[args] = fn(*args)
		return result
	return memoized
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e

def rev(o):
	if o == 16 or o == 17 or o == 18 or (o == 19) or (9 - o >= 0):
		if o >= 6 and o < 10:
			p = (10 - o) * 60 + 1
		elif o >= 16 and o < 20:
			p = (20 - o) * 60 + 2
		else:
			p = 10 * o
	else:
		p = 0
		while o > 0:
			r = o % 10
			o = o // 10
			p = p * 10 + r
	return p
s = input()
a = list(s)
for i in a:
	if i == ':':
		a.remove(i)
b = a[:2]
c = a[2:]
e = c[::-1]
g = b[::-1]
k = 0
if b == e:
	k = 0
else:
	h = ''.join(map(str, c))
	g = ''.join(map(str, g))
	o = ''.join(map(str, b))
	o = int(o)
	h = int(h)
	g = int(g)
	if g == 60 or g == 70 or g == 80 or (g == 90) or (g == 61) or (g == 71) or (g == 81) or (g == 91):
		k = -1
	else:
		k = g - h
	if k < 0:
		l = 60 - h
		if o == 23:
			o = 0
		else:
			o += 1
			o = rev(o)
		k = o + l
print(k)
import operator
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e


def pallindrome(a, b):
	a_str = ''
	b_str = ''
	if a <= 9:
		a_str += '0'
	if b <= 9:
		b_str += '0'
	a_str += str(a)
	b_str += str(b)
	fwd = a_str + b_str
	return fwd == fwd[::-1]
(a, b) = map(int, str(input()).split(':'))
cnt = 0
while not pallindrome(a, b):
	cnt += 1
	if b + 1 <= 59:
		b = b + 1
		if pallindrome(a, b):
			break
	else:
		b = 0
		a = (a + 1) % 24
		if pallindrome(a, b):
			break
print(cnt)


(h, m) = input().split(':')
h = int(h)
m = int(m)
t = 0
if h // 10 == m % 10 and h % 10 == m // 10:
	print(0)
else:
	while True:
		m += 1
		t += 1
		if m == 60:
			h += 1
			m = 0
		if h == 24:
			h = 0
		if h // 10 == m % 10 and h % 10 == m // 10:
			print(t)
			break


time = input()
t = 0
a = [int(time[0]), int(time[1]), int(time[3]), int(time[4])]

def timepp(a):
	if a[0] == 2 and a[1] == 3 and (a[2] == 5) and (a[3] == 9):
		for i in range(4):
			a[i] = 0
		return a
	if int(a[2]) * 10 + int(a[3]) < 59:
		if int(a[3]) < 9:
			a[3] += 1
		else:
			a[3] = 0
			a[2] += 1
	else:
		a[2] = 0
		a[3] = 0
		if int(a[1]) < 9:
			a[1] += 1
		else:
			a[1] = 0
			a[0] += 1
	return a
while a[0] != a[3] or a[1] != a[2]:
	t += 1
	a = timepp(a)
print(t)


def f(s):
	for i in range(len(s)):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True
(a, b) = list(map(int, input().split(':')))
ans = 0
while not f((str(a) if len(str(a)) == 2 else '0' + str(a)) + (str(b) if len(str(b)) == 2 else '0' + str(b))):
	b += 1
	if b == 60:
		b = 0
		a += 1
		if a == 24:
			a = 0
	ans += 1
print(ans)


(hrs, mins) = [int(x) for x in input().split(':')]
count = 0
while hrs // 10 != mins % 10 or hrs % 10 != mins // 10:
	count += 1
	mins += 1
	if mins >= 60:
		mins %= 60
		hrs += 1
	if hrs >= 24:
		hrs %= 24
print(count)


def checker(h, m):
	if len(m) == 1:
		m = '0{}'.format(m)
	return h == int(m[1] + m[0])

def palindromeTime(time):
	(h, m) = (int(val) for val in time.split(':'))
	sleeped_minutes = 0
	while True:
		if m < 60:
			if checker(h, str(m)):
				return sleeped_minutes
			m += 1
			sleeped_minutes += 1
		else:
			m = 0
			h += 1
		if h == 24:
			h = 0
sleeping_time = input()
print(palindromeTime(sleeping_time))


time = input()
b = time.find(':')
h = int(time[:b])
m = int(time[b + 1:])
for i in range(60 * 24):
	time = '0' * (2 - len(str(h))) + str(h) + '0' * (2 - len(str(m))) + str(m)
	if time == time[::-1]:
		print(i)
		return
	m += 1
	h += m // 60
	h %= 24
	m %= 60


def tostring(h):
	if h < 10:
		return '0' + str(h)
	return str(h)

def incmin(s):
	h = int(s[0:2])
	m = int(s[3:5])
	m += 1
	if m == 60:
		h += 1
		m = 0
	if h == 24:
		h = 0
	return tostring(h) + ':' + tostring(m)

def palindrom(s):
	return s[:] == s[::-1]
s = input()
towait = 0
while not palindrom(s):
	towait += 1
	s = incmin(s)
print(towait)


import sys

def main():
	time = sys.stdin.readline().strip()
	if time[::-1] in time + time:
		print(0)
		return
	(hrs, mins) = map(int, time.split(':'))
	elapsed = 0
	while time[::-1] not in time + time:
		elapsed += 1
		(inc, mins) = divmod(mins + 1, 60)
		hrs = (hrs + inc) % 24
		time = '{:02d}:{:02d}'.format(hrs, mins)
	print(elapsed)
main()


(h, m) = map(int, input().split(':'))
ans = 0
while int((('0' if m < 10 else '') + str(m))[::-1]) != h:
	ans += 1
	m += 1
	if m == 60:
		m = 0
		h += 1
		if h == 24:
			h = 0
print(ans)


from collections import deque
from sys import stdin
lines = deque((line.strip() for line in stdin.readlines()))

def nextline():
	return lines.popleft()

def types(cast):
	return tuple((int(x) for x in nextline().split()))

def ints():
	return types(int)

def strs():
	return nextline().split()

def main():
	t = nextline().split(':')
	w = 0
	while True:
		if t[0][::-1] == t[1]:
			print(w)
			return
		m = (int(t[1]) + 1) % 60
		if m == 0:
			h = (int(t[0]) + 1) % 24
			t[0] = '{:02d}'.format(h)
		t[1] = '{:02d}'.format(m)
		w += 1
main()


(m, n) = map(int, input().split(':'))
cnt = 0
while m % 10 != n // 10 or m // 10 != n % 10:
	cnt += 1
	n += 1
	if n >= 60:
		m += 1
		n %= 60
	if m >= 24:
		m %= 24
print(cnt)


(a, b) = map(int, input().split(':'))
cnt = 0
while True:
	if str(a // 10) + str(a % 10) + str(b // 10) + str(b % 10) != (str(a // 10) + str(a % 10) + str(b // 10) + str(b % 10))[::-1]:
		if b != 59:
			b += 1
		elif a != 23:
			a += 1
			b = 0
		else:
			print(cnt + 1)
			exit(0)
	else:
		print(cnt)
		exit(0)
	cnt += 1


st = input()
from datetime import datetime as dt
import datetime
tda = dt.strptime(st, '%H:%M')

def isP(s):
	for i in range(len(s)):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True
for i in range(3600):
	new = tda + datetime.timedelta(minutes=i)
	a = new.strftime('%H:%M')
	if isP(a):
		print(i)
		break


def main():
	(h, m) = [int(ai) for ai in input().split(':')]
	ans = 0
	while True:
		s = str(h // 10) + str(h % 10) + str(m // 10) + str(m % 10)
		t = s[::-1]
		if s == t:
			break
		m += 1
		if m == 60:
			m = 0
			h += 1
		if h == 24:
			h = 0
		ans += 1
	print(ans)
main()


from bisect import bisect
l = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412, 1440]
(s, k) = map(int, input().split(':'))
p = s * 60 + k
k = bisect(l, p)
if p == l[k - 1]:
	print('0')
else:
	print(l[k] - p)


def inverted(n):
	return n // 10 + n % 10 * 10

def get_time(h, m):
	return 60 * h + m
time = input()
(hours, minutes) = (int(time[0:2]), int(time[3:5]))
if inverted(hours) == minutes:
	print(0)
elif hours % 10 > 5 or (hours % 10 == 5 and minutes > inverted(hours)):
	best_hours = (hours + 5) // 10 * 10
	print(get_time(best_hours, inverted(best_hours)) - get_time(hours, minutes))
elif get_time(hours, minutes) > get_time(23, 32):
	print(60 - minutes)
elif minutes > inverted(hours):
	print(60 - minutes + inverted(hours + 1))
else:
	print(inverted(hours) - minutes)


def reverse(string):
	l = list(string)
	l.reverse()
	return ''.join(l)

def is_palindrome(string):
	rev = reverse(string)
	for i in range(len(string)):
		if string[i] != rev[i]:
			return False
	return True
string = input()
(hour, minutes) = map(int, string.split(':'))
c = 0
while not is_palindrome(string):
	c += 1
	minutes += 1
	if minutes == 60:
		minutes = 0
		hour += 1
	if hour == 24:
		hour = 0
	minstr = '0' + str(minutes) if minutes < 10 else str(minutes)
	hrstr = '0' + str(hour) if hour < 10 else str(hour)
	string = hrstr + ':' + minstr
print(c)


def solve(time):
	time = [int(t) for t in time if t.isdigit()]
	ans = 0
	while time[0] != time[3] or time[1] != time[2]:
		(h, m) = (time[0] * 10 + time[1], time[2] * 10 + time[3])
		m += 1
		if m >= 60:
			h += 1
			m -= 60
			if h >= 24:
				h -= 24
		(time[0], time[1], time[2], time[3]) = (h // 10, h % 10, m // 10, m % 10)
		ans += 1
	print(ans)
data = input()
solve(data)


s1 = input().split(':')
count = 0
hr = int(s1[0])
mint = int(s1[1])
s = s1[0] + ':' + s1[1]
while s != s[::-1]:
	count += 1
	mint += 1
	if mint == 60:
		hr += 1
		mint = 0
	if hr == 24:
		hr = 0
	if hr < 10:
		hr1 = '0' + str(hr)
	else:
		hr1 = str(hr)
	if mint < 10:
		mint1 = '0' + str(mint)
	else:
		mint1 = str(mint)
	s = hr1 + ':' + mint1
print(count)


def palidrome(hr, mn):
	if hr <= 9:
		hr = '0' + str(hr)
	else:
		hr = str(hr)
	if mn <= 9:
		mn = '0' + str(mn)
	else:
		mn = str(mn)
	if hr[::-1] == mn:
		return True
	else:
		return False
(hr, mn) = map(int, input().split(':'))
pali = False
ans = 0
while pali != True:
	if mn == 60:
		mn = 0
		hr = int(hr) + 1
		if hr == 24:
			hr = 0
	if palidrome(hr, mn):
		pali = True
		break
	mn = int(mn) + 1
	ans += 1
print(ans)


a = list(map(str, input().split(':')))
a = list(a[0][0] + a[0][1] + a[1][0] + a[1][1])
s = 0
while a != a[::-1]:
	a[3] = str(int(a[3]) + 1)
	if a[3] == '10':
		a[3] = '0'
		a[2] = str(int(a[2]) + 1)
	if a[2] == '6':
		a[2] = '0'
		a[1] = str(int(a[1]) + 1)
	if a[0] != '2' and a[1] == '10':
		a[1] = '0'
		a[0] = str(int(a[0]) + 1)
	if a[0] + a[1] == '24':
		(a[0], a[1], a[2], a[3]) = ('0', '0', '0', '0')
	s += 1
print(s)


(a, b) = (int(i) for i in input().split(':'))

def ispal(a, b):
	if a < 10:
		a = '0' + str(a)
	if b < 10:
		b = '0' + str(b)
	a = str(a)
	b = str(b)
	if a[-1] == b[-2] and a[-2] == b[-1]:
		return True
x = 0
while True:
	if ispal(a, b):
		print(x)
		quit()
	b += 1
	x += 1
	if b == 60:
		a += 1
		b = 0
	if a == 24:
		a = 0


def is_pal(hh, mm):
	if mm[::-1] == hh and hh[::-1] == mm:
		return True
	return False

def form(s):
	if len(s) == 1:
		s = '0' + s
	return s
(h, m) = input().split(':')
i = 0
while not is_pal(h, m):
	m = int(m) + 1
	if m == 60:
		m = '00'
		h = str(int(h) + 1)
	if int(h) == 24:
		h = '00'
	m = str(m)
	h = form(h)
	m = form(m)
	i += 1
print(i)


def main():
	(h, m) = map(int, input().split(':'))
	(d1, d2, d3, d4) = (0, 0, 0, 0)
	for i in range(24 * 60):
		d1 = h // 10
		d2 = h % 10
		d3 = m // 10
		d4 = m % 10
		if d1 == d4 and d2 == d3:
			print(i)
			break
		m += 1
		if m == 60:
			m = 0
			h += 1
		if h == 24:
			h = 0
main()


n = ''.join(input().split(':'))
cnt = 0
while n != n[::-1]:
	if n == '2359':
		cnt += 1
		break
	a = int(n[0:2]) * 60
	b = int(n[2:])
	ab = a + b + 1
	a = [str(ab // 60).zfill(2)]
	b = [str(ab % 60).zfill(2)]
	n = ''.join(a + b)
	cnt += 1
print(cnt)


(h, m) = [int(x) for x in input().split(':')]
ans = 0

def padL(s):
	while len(s) < 2:
		s = '0' + s
	return s

def palindrome():
	t = padL(str(h)) + padL(str(m))
	return t == t[::-1]
while not palindrome():
	m += 1
	if m == 60:
		h += 1
		m = 0
		if h == 24:
			h = 0
	ans += 1
print(ans)


def Func(time):
	(a, b) = time.split(':')
	r = a[::-1]
	if a == '23' and int(b) > 32:
		return 60 - int(b)
	ls = [(0, 0), (1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (10, 1), (11, 11), (12, 21), (13, 31), (14, 41), (15, 51), (20, 2), (21, 12), (22, 22), (23, 32)]
	l = list(map(lambda x: x[0] * 60 + x[1], ls))
	N = int(a) * 60 + int(b)
	for i in range(len(l)):
		if l[i] >= N:
			return l[i] - N
print(Func(input()))


ch = input()
ch1 = ch[0] + ch[1]
ch2 = ch[3] + ch[4]
a = int(ch1)
b = int(ch2)
s = 0

def pal(a, b):
	return a == b % 10 * 10 + b // 10
if pal(a, b):
	print(0)
else:
	while pal(a, b) == False:
		s = s + 1
		if b != 59:
			b = b + 1
		else:
			b = 0
			if a != 23:
				a = a + 1
			else:
				a = 0
	print(s)


l = input().split(':')
a = l[0]
b = l[1]
u = int(a)
v = int(b)
minutes = 0
while 1:
	if u < 10:
		a = '0' + str(u)
	else:
		a = str(u)
	if v < 10:
		b = '0' + str(v)
	else:
		b = str(v)
	b = b[::-1]
	if a == b:
		break
	u = u + (v + 1) // 60
	if u == 24:
		u = 0
	v = (v + 1) % 60
	minutes += 1
print(minutes)


(h, m) = map(int, input().split(':'))
ans = 0
l = [[0, 0], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [10, 1], [11, 11], [12, 21], [13, 31], [14, 41], [15, 51], [20, 2], [21, 12], [22, 22], [23, 32]]
while not [h, m] in l:
	ans += 1
	m += 1
	h += m // 60
	m %= 60
	h %= 24
print(ans)


class CodeforcesTask816ASolution:

	def __init__(self):
		self.result = ''
		self.hour = []

	def read_input(self):
		self.hour = [int(x) for x in input().split(':')]

	def process_task(self):
		m = 0
		while not '{0:02d}{1:02d}'.format(self.hour[0], self.hour[1]) == '{0:02d}{1:02d}'.format(self.hour[0], self.hour[1])[::-1]:
			self.hour[1] += 1
			if self.hour[1] >= 60:
				self.hour[1] = 0
				self.hour[0] += 1
				if self.hour[0] >= 24:
					self.hour[0] = 0
			m += 1
		self.result = str(m)

	def get_result(self):
		return self.result
Solution = CodeforcesTask816ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def isPalindrome(st):
	for idx in range(0, len(st) // 2):
		if st[idx] != st[len(st) - idx - 1]:
			return False
	return True

def incrementTime(st):
	(hh, mm) = st.split(':')
	mm = int(mm)
	hh = int(hh)
	mm += 1
	if mm > 59:
		mm = 0
		hh += 1
		if hh > 23:
			hh = 0
	mm = str(mm)
	hh = str(hh)
	if len(mm) < 2:
		mm = '0' + mm
	if len(hh) < 2:
		hh = '0' + hh
	return ':'.join([hh, mm])

def main(s):
	count = 0
	while not isPalindrome(s):
		s = incrementTime(s)
		count += 1
	print(count)
main(input())


def reverse(x):
	ones = x % 10
	tens = x // 10
	return 10 * ones + tens
st = input()
hour = int(st[0:2])
minute = int(st[3:])
if hour == 23:
	if minute <= 32:
		answer = 32 - minute
	else:
		answer = 60 - minute
else:
	checkpal = reverse(hour)
	if checkpal <= 59 and minute <= checkpal:
		answer = checkpal - minute
	else:
		answer = 0
		thehour = hour + 1
		theminute = reverse(thehour)
		while theminute > 59:
			answer = answer + 60
			thehour = thehour + 1
			theminute = reverse(thehour)
		answer = answer + theminute + (60 - minute)
print(answer)


time = input()
x = int(time[0])
y = int(time[3]) * 10 + int(time[4])
z = int(time[1])
temp = z * 10 + x
if x == 0:
	if z < 5:
		if y > temp:
			t1 = (z + 1) * 10 + x
			print(60 - y + t1)
		else:
			print(temp - y)
	elif z == 5:
		if y <= temp:
			print(temp - y)
		else:
			_min = 60 - y
			_min1 = 60 * (10 - z - 1)
			print(_min + _min1 + 1)
	elif z > 5:
		_min = 60 - y
		_min1 = 60 * (10 - z - 1)
		print(_min + _min1 + 1)
elif x == 1:
	if z < 5:
		if y > temp:
			t1 = (z + 1) * 10 + x
			print(60 - y + t1)
		else:
			print(temp - y)
	elif z == 5:
		if y <= temp:
			print(temp - y)
		else:
			_min = 60 - y
			hr = x * 10 + z
			_min1 = 60 * (20 - hr - 1)
			print(_min + _min1 + 2)
	elif z > 5:
		_min = 60 - y
		hr = x * 10 + z
		_min1 = 60 * (20 - hr - 1)
		print(_min + _min1 + 2)
elif x == 2:
	if z <= 2:
		if y > temp:
			t1 = (z + 1) * 10 + x
			print(60 - y + t1)
		else:
			print(temp - y)
	if z == 3:
		if y <= temp:
			print(temp - y)
		else:
			print(60 - y)


(hh, mm) = input().split(':')
(h, m) = map(int, (hh, mm))
t1 = 60 * h + m
h1 = h
if hh[1] < '6':
	if mm > hh[::-1]:
		h1 = h + 1
if h1 == 24:
	h1 = 0
elif h1 % 10 > 5:
	h1 = (h1 // 10 + 1) * 10
t2 = 60 * h1 + int(str(h1).zfill(2)[::-1])
if t2 < t1:
	t2 += 24 * 60
print(t2 - t1)


import datetime
(h, m) = list(map(int, input().split(':')))
t = datetime.datetime(1, 1, 1, h, m, 0)
c = 0
while True:
	if str(t.time())[:-3] == str(t.time())[-4::-1]:
		print(c)
		exit()
	c += 1
	t += datetime.timedelta(minutes=1)


def solve(h, m):
	ans = 0
	while f'{h:02d}:{m:02d}' != ''.join(reversed(f'{h:02d}:{m:02d}')):
		ans += 1
		m += 1
		if m == 60:
			m = 0
			h += 1
			if h == 24:
				h = 0
	return ans
(h, m) = map(int, input().split(':'))
print(solve(h, m))


(h, m) = input().split(':')
hh = int(h)
mm = int(m)
mins = 0
while h[::-1] != m:
	mm += 1
	mins += 1
	if mm == 60:
		if hh == 23:
			hh = 0
			mm = 0
		else:
			hh += 1
			mm = 0
	if hh <= 9:
		h = '0' + str(hh)
	else:
		h = str(hh)
	if mm <= 9:
		m = '0' + str(mm)
	else:
		m = str(mm)
print(mins)


(h, m) = map(int, input().split(':'))
t = h * 60 + m
ans = 10 ** 10
for i in range(24 * 60):
	H = str(i // 60)
	M = str(i % 60)
	if len(H) < 2:
		H = '0' + H
	if len(M) < 2:
		M = '0' + M
	s = H + ':' + M
	if s != s[::-1]:
		continue
	s = int(H) * 60 + int(M)
	if t <= s:
		ans = min(ans, s - t)
	else:
		ans = min(ans, 24 * 60 - t + s)
print(ans)


(x, y) = map(int, input().split(':'))
for i in range(24 * 60):
	k = (x + (i + y) // 60) % 24
	z = (i + y) % 60
	s = str(k) + ':' + str(z)
	if len(str(k)) == 1:
		s = '0' + str(k) + ':' + str(z)
	if len(str(z)) == 1:
		s = str(k) + ':' + '0' + str(z)
	if len(str(k)) == 1 and len(str(z)) == 1:
		s = '0' + str(k) + ':' + '0' + str(z)
	if s == s[::-1]:
		print(i)
		break


(hh, mm) = list(map(int, input().split(':')))
ans = 0
for i in range(1440):
	t = hh * 60 + mm + i
	hi = str(t // 60 % 24)
	if len(hi) == 1:
		hi = '0' + hi
	mi = str(t % 60)
	if len(mi) == 1:
		mi = '0' + mi
	s = hi + ':' + mi
	if list(s) == list(reversed(list(s))):
		ans = i
		break
print(ans)


s = input()
h = int(s[:2])
m = int(s[3:])

def ispalin(h, m):
	s = '%02d:%02d' % (h, m)
	return s == s[::-1]
for d in range(999999):
	if ispalin(h, m):
		print(d)
		break
	m += 1
	if m == 60:
		h = (h + 1) % 24
		m = 0


def main():
	a = input()
	number = parseInput(a)
	count = 0
	while not isPalindrome(number):
		number = addOneTo(number)
		count += 1
	print(count)

def isPalindrome(number):
	test = str(number)
	for i in range(4 - len(test)):
		test = '0' + test
	return test[0] == test[3] and test[1] == test[2]

def addOneTo(number):
	number += 1
	if number % 1000 % 100 == 60:
		number += 100
		number -= 60
	if number / 100 == 24:
		number -= 2400
	return number

def parseInput(time):
	number = int(time[0]) * 1000 + int(time[1]) * 100 + int(time[3]) * 10 + int(time[4])
	return number
main()


def a(h, m, i):
	m += i
	h += m // 60
	return (h % 24, m % 60)
(h, m) = (int(v) for v in input().split(':'))
s = lambda h, m: '%02d:%02d' % (h, m)
p = lambda s: s == s[::-1]
print(next((i for i in range(1440) if p(s(*a(h, m, i))))))


s = input()
s = s[0:2] + s[3:5]

def check(s):
	if s == s[::-1]:
		return 1
	else:
		return 0
count = 0
while 1:
	a1 = s[0:2]
	b1 = s[2:4]
	a = int(a1)
	b = int(b1)
	if check(s) == 1:
		break
	else:
		count += 1
		b += 1
		if b == 60:
			b = 0
			b1 = '00'
			a += 1
			if a == 24:
				a = 0
				a1 = '00'
			elif a >= 10:
				a1 = str(a)
			else:
				a1 = '0' + str(a)
		elif b >= 10:
			b1 = str(b)
		else:
			b1 = '0' + str(b)
	s = a1 + b1
print(count)


t = input()
ans = 0
while t != t[::-1]:
	(h, m) = map(int, t.split(':'))
	m += 1
	h += m // 60
	m %= 60
	h %= 24
	ans += 1
	t = '{}{}:{}{}'.format(str(h // 10), str(h % 10), str(m // 10), str(m % 10))
print(ans)


L = input().split(':')

def check(a, b):
	return b[::-1] == a or a[::-1] == b
i = 0
h = L[0]
m = L[1]
while not check(h, m):
	x = int(h)
	y = int(m)
	y += 1
	i += 1
	x += y // 60
	x = x % 24
	y = y % 60
	h = str(x)
	m = str(y)
	if len(h) == 1:
		h = '0' + h
	if len(m) == 1:
		m = '0' + m
print(i)


s = input()
(h, m) = map(int, s.split(':'))
t = h * 60 + m
for i in range(t, t + 1440):
	th = i % 1440 // 60
	tm = i % 1440 % 60
	ts = '{:02d}:{:02d}'.format(th, tm)
	if ts == ts[::-1]:
		print(i - t)
		break


(a, b) = map(int, input().split(':'))
cnt = 0
while not (a // 10 == b % 10 and a % 10 == b // 10):
	b += 1
	if b == 60:
		a += 1
		b = 0
	if a == 24:
		a = 0
	cnt += 1
print(cnt)


(a, b) = map(int, input().split(':'))
rev = 0
n = a
while n > 0:
	r = n % 10
	rev = rev * 10 + r
	n = n // 10
if a < 10:
	rev = rev * 10
if a == 23 and b > 32:
	print(60 - b)
elif a >= 5 and a < 10:
	if a == 5 and b <= 50:
		print(50 - b)
	else:
		ans = (10 - a - 1) * 60 + 60 - b + 1
		print(ans)
elif a >= 15 and a < 20:
	if a == 15 and b <= 51:
		print(51 - b)
	else:
		ans = (20 - a - 1) * 60 + 60 - b + 2
		print(ans)
elif b <= rev:
	print(rev - b)
else:
	rev = 0
	n = a + 1
	while n > 0:
		r = n % 10
		rev = rev * 10 + r
		n = n // 10
	if a < 10:
		rev = rev * 10
	ans = 60 - b + rev
	print(ans)


(h, m) = map(str, input().split(':'))
p = int(h[::-1])
q = int(m)
if p >= q:
	if 9 >= p // 10 >= 6:
		if p % 10 == 0:
			print(601 - int(h) * 60 - q)
		else:
			print(1202 - int(h) * 60 - q)
	else:
		print(p - q)
elif p == 50:
	print(601 - int(h) * 60 - q)
elif p == 51:
	print(1202 - int(h) * 60 - q)
else:
	p = int(h) + 1
	s = str(p // 10) + str(p % 10)
	p = int(s) % 24
	s = str(p // 10) + str(p % 10)
	p = int(s[::-1])
	print(p + (60 - q) % 60)


from datetime import date, datetime, timedelta

def is_palindrom(date_str):
	return date_str == date_str[::-1]
date_str = input()
format = '%H:%M'
init = datetime.strptime(date_str, format)
now = datetime.strptime(date_str, format)
while not is_palindrom(now.strftime(format)):
	now += timedelta(minutes=1)
diff = int((now - init).seconds / 60)
print(diff)


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left

def palindrome(h, m):
	h = str(h)
	if len(h) == 1:
		h = '0' + h
	m = str(m)
	if len(m) == 1:
		m = '0' + m
	last = h + m
	return last == last[::-1]
(h, m) = map(int, input().split(':'))
ans = 0
while not palindrome(h, m):
	m += 1
	if m == 60:
		m = 0
		h += 1
		if h == 24:
			h = 0
	ans += 1
print(ans)


(h, m) = map(int, input().split(':'))
i = 0
a = h
b = m
while 1:
	if h % 10 == m // 10 and h // 10 == m % 10:
		break
	m += 1
	i += 1
	if m > 59:
		h += 1
		h = h % 24
		m = 0
print(i)


def palindrome(n):
	p = []
	for i in range(len(n) - 1, -1, -1):
		p.append(n[i])
	n = list(n)
	for i in range(len(n)):
		if p[i] != n[i]:
			return 0
	return 1
t = 0
n = input()
while palindrome(n) != 1:
	t += 1
	z = n[:2]
	zz = n[3:]
	if len(str(int(zz) + 1)) == 1:
		zz = '0' + str(int(zz) + 1)
	elif int(zz) + 1 > 59:
		zz = '00'
		if len(str(int(z) + 1)) == 1:
			z = '0' + str(int(z) + 1)
		elif int(z) + 1 > 23:
			z = '00'
		else:
			z = str(int(z) + 1)
	else:
		zz = int(zz) + 1
	n = str(z) + ':' + str(zz)
print(t)


h = input()
k = h.split(':')
m = k[0]
n = k[1]
m1 = int(m)
n1 = int(n)
r = int(m[::-1])
rev = int(n[::-1])
if m1 == rev:
	print('0')
elif n1 < r and r < 60:
	print(r - n1)
elif m1 == 23:
	print(60 - n1)
elif m1 >= 5 and m1 < 10:
	print((10 - m1 - 1) * 60 + (60 - n1) + 1)
elif m1 >= 15 and m1 < 20:
	print((20 - m1 - 1) * 60 + (60 - n1) + 2)
else:
	n = r + 10
	print(n + 60 - n1)


(h, m) = list(map(int, input().split(':')))
kk = 0
while h // 10 != m % 10 or h % 10 != m // 10:
	kk += 1
	m += 1
	if m == 60:
		m = 0
		h += 1
		h %= 24
print(kk)


(a, b) = list(map(int, input().split(':')))
aa = a % 10 * 10 + a // 10
bb = b % 10 * 10 + b // 10
ans = 0
while aa != b:
	b += 1
	if b == 60:
		b -= 60
		a += 1
		if a == 24:
			a -= 24
		aa = a % 10 * 10 + a // 10
	ans += 1
print(ans)


def int2Str(a):
	aa = str(a)
	return '0' * (2 - len(aa)) + aa

def isPar(hh, mm):
	s = int2Str(hh) + int2Str(mm)
	p = 0
	q = len(s) - 1
	while p < q:
		if s[p] != s[q]:
			return False
		p += 1
		q -= 1
	return True
(hh, mm) = [int(x) for x in input().strip().split(':')]
i = 0
while not isPar(hh, mm):
	mm += 1
	if mm == 60:
		mm = 0
		hh += 1
		if hh == 24:
			hh = 0
	i += 1
print(i)


s = input()
l = s.split(':', 2)
h = int(l[0])
m = int(l[1])
if h >= 0 and h < 1:
	if m > 0:
		print(60 - m + 10)
	else:
		print(0 - m)
if h >= 1 and h < 2:
	if m > 10:
		print(60 - m + 20)
	else:
		print(10 - m)
if h >= 2 and h < 3:
	if m > 20:
		print(60 - m + 30)
	else:
		print(20 - m)
if h >= 3 and h < 4:
	if m > 30:
		print(60 - m + 40)
	else:
		print(30 - m)
if h >= 4 and h < 5:
	if m > 40:
		print(60 - m + 50)
	else:
		print(40 - m)
if h >= 5 and h < 6:
	if m > 50:
		print(300 - m + 1)
	else:
		print(50 - m)
if h >= 6 and h < 7:
	print(240 - m + 1)
if h >= 7 and h < 8:
	print(180 - m + 1)
if h >= 8 and h < 9:
	print(120 - m + 1)
if h >= 9 and h < 10:
	print(60 - m + 1)
if h >= 10 and h < 11:
	if m > 1:
		print(60 - m + 11)
	else:
		print(1 - m)
if h >= 11 and h < 12:
	if m > 11:
		print(60 - m + 21)
	else:
		print(11 - m)
if h >= 12 and h < 13:
	if m > 21:
		print(60 - m + 31)
	else:
		print(21 - m)
if h >= 13 and h < 14:
	if m > 31:
		print(60 - m + 41)
	else:
		print(31 - m)
if h >= 14 and h < 15:
	if m > 41:
		print(60 - m + 51)
	else:
		print(41 - m)
if h >= 15 and h < 16:
	if m > 51:
		print(300 - m + 2)
	else:
		print(51 - m)
if h >= 16 and h < 17:
	print(240 - m + 2)
if h >= 17 and h < 18:
	print(180 - m + 2)
if h >= 18 and h < 19:
	print(120 - m + 2)
if h >= 19 and h < 20:
	print(60 - m + 2)
if h >= 20 and h < 21:
	if m > 2:
		print(60 - m + 12)
	else:
		print(2 - m)
if h >= 21 and h < 22:
	if m > 12:
		print(60 - m + 22)
	else:
		print(12 - m)
if h >= 22 and h < 23:
	if m > 22:
		print(60 - m + 32)
	else:
		print(22 - m)
if h >= 23 and h < 24:
	if m > 32:
		print(60 - m)
	else:
		print(32 - m)


palindrome = lambda s: s == s[::-1]
hour = input()
toWait = 0
(heure, minute) = (int(hour[0] + hour[1]), int(hour[3] + hour[4]))
h = hour[0] + hour[1] + hour[3] + hour[4]
while not palindrome(h):
	if heure == 23 and minute == 59:
		(heure, minute) = (0, 0)
	elif minute < 59:
		minute += 1
	else:
		minute = 0
		heure += 1
	(stH, stM) = (str(heure), str(minute))
	if len(stH) < 2:
		stH = '0' + stH
	if len(stM) < 2:
		stM = '0' + stM
	h = stH + stM
	toWait += 1
print(toWait)


def f(a):
	r = 0
	if a == 0:
		return 0
	elif a < 10:
		return a * 10
	elif a >= 10:
		r = a % 10 * 10 + a // 10
		return r
(x, y) = input().split(':')
a = int(x)
b = int(y)
ans = 0
if a < 6 and b <= f(a) or (a > 9 and b <= f(a)):
	ans = f(a) - b
elif a < 5 or a > 9:
	ans = 60 - b + f(a + 1)
elif a >= 5 and a <= 9:
	ans = 60 - b + (10 - (a + 1)) * 60 + 1
if a == 23 and b > f(a):
	ans = 60 - b
if a > 15 and a < 20 or (a == 15 and b > f(a)):
	ans = 60 - b + (20 - (a + 1)) * 60 + 2
print(ans)


a = list(map(str, input().split(':')))
cnt = 0
while a[0] + a[1] != (a[0] + a[1])[::-1]:
	cnt += 1
	a[1] = str((int(a[1]) + 1) % 60)
	if len(a[1]) == 1:
		a[1] = '0' + a[1]
	if a[1] == '00':
		a[0] = str((int(a[0]) + 1) % 24)
		if len(a[0]) == 1:
			a[0] = '0' + a[0]
print(cnt)


(h, m) = map(int, input().split(':'))
for i in range(999):
	if h == 10 * (m % 10) + m // 10:
		print(i)
		break
	(h, m) = (h, m + 1) if m < 59 else ((h + 1) % 24, 0)


x = input().split(':')
dict = {'00': '00', '01': '10', '02': '20', '03': '30', '04': '40', '05': '50', '10': '01', '11': '11', '12': '21', '13': '31', '14': '41', '15': '51', '20': '02', '21': '12', '22': '22', '23': '32', '24': '00'}
if x[0] in dict and int(dict[x[0]]) >= int(x[1]):
	ans = int(dict[x[0]]) - int(x[1])
	print(ans)
else:
	temp = int(x[0]) + 1
	key = str(temp)
	if len(str(temp)) == 1:
		key = '0' + str(temp)
	while key not in dict:
		key = int(key) + 1
		key = str(key)
	print((int(key) - int(x[0]) - 1) * 60 + (60 - int(x[1]) + int(dict[key])))


n = input()
l = n.split(':')
h = int(l[0])
m = int(l[1])
res = 0
while True:
	sH = '%0*d' % (2, h)
	sM = '%0*d' % (2, m)
	if sH == sM[::-1]:
		break
	else:
		m += 1
	if m == 60:
		h += 1
		m = 0
	if h == 24:
		h = 0
	res += 1
print(res)


s = input()
h = int(s[0:2])
m = int(s[3:5])
mm = h * 60 + m
for i in range(mm, 24 * 60 + 1):
	h2 = i // 60
	m2 = i % 60
	if h2 // 10 == m2 % 10 and h2 % 10 == m2 // 10 or i == 24 * 60:
		print(i - mm)
		quit()


def next_minute(s):
	if s == '2359':
		return '0000'
	if s[2:] == '59':
		ans = str(int(s[:2]) + 1) + '00'
		if len(ans) == 3:
			ans = '0' + ans
		return ans
	min_ans = str(int(s[2:]) + 1)
	if len(min_ans) == 1:
		min_ans = '0' + min_ans
	return s[:2] + min_ans
s = input()
s = s[:2] + s[-2:]
for i in range(1000000):
	if s == s[::-1]:
		print(i)
		break
	s = next_minute(s)


def is_pal(tim):
	if tim[0] % 10 == int(tim[1] / 10) and int(tim[0] / 10) == tim[1] % 10:
		return True
	else:
		return False

def add_minute(tim):
	tim[1] = tim[1] + 1
	if tim[1] == 60:
		tim[1] = 0
		tim[0] = tim[0] + 1
	if tim[0] == 24:
		tim[0] = 0
tim = list(map(int, input().split(':')))
k = 0
b = True
while b:
	if is_pal(tim):
		b = False
		print(k)
	else:
		k = k + 1
		add_minute(tim)


(h, m) = input().split(':')
(h, m) = (int(h), int(m))
count = 0

def swap(n):
	if n >= 10:
		a = n % 10 * 10
		n = a + n // 10
		return n
	else:
		return n * 10

def pal(h, m):
	if swap(h) == m and swap(m) == h:
		return False
	else:
		return True
while pal(h, m):
	if m < 59:
		m = m + 1
		count = count + 1
	elif m == 59:
		if h == 23:
			h = 0
			m = 0
			count = count + 1
		else:
			h = h + 1
			m = 0
			count = count + 1
print(count)


t = list(map(int, input().split(':')))

def isPal(t):
	return t[0] // 10 == t[1] % 10 and t[0] % 10 == t[1] // 10

def next():
	t[1] += 1
	if t[1] == 60:
		t[1] = 0
		t[0] += 1
	if t[0] == 24:
		t[0] = 0
ans = 0
while not isPal(t):
	next()
	ans += 1
print(ans)


s = input()
(h, m) = s.split(':')
(h, m) = (int(h), int(m))

def is_pal(h, m):
	h = str(h)
	m = str(m)
	if len(h) == 1:
		h = '0' + h
	if len(m) == 1:
		m = '0' + m
	return h == m[::-1]

def output(h, m):
	(h, m) = (str(h), str(m))
	if len(h) == 1:
		h = '0' + h
	if len(m) == 1:
		m = '0' + m
	print(h + ':' + m)
i = 0
while True:
	if is_pal(h, m):
		print(i)
		break
	m += 1
	if m == 60:
		m = 0
		h += 1
		h %= 24
	i += 1


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	s = S()
	a = int(s[:2])
	b = int(s[3:])
	c = a // 10 + a % 10 * 10
	if c < 60 and c >= b:
		return c - b
	k = 1
	a += 1
	a %= 24
	c = a // 10 + a % 10 * 10
	while c >= 60:
		k += 1
		a += 1
		a %= 24
		c = a // 10 + a % 10 * 10
	return c - b + 60 * k
print(main())


def reverse(s):
	if s < 10:
		s = '0{}'.format(s)
	else:
		s = str(s)
	return int(s[::-1])

def main(s):
	(hh, mm) = [int(item) for item in s.split(':')]
	if hh == 23 and mm > 32:
		return 60 - mm
	elif 16 <= hh <= 19 or (hh == 15 and mm > 51):
		return (20 - hh) * 60 + 2 - mm
	elif 6 <= hh <= 9 or (hh == 5 and mm > 50):
		return (10 - hh) * 60 + 1 - mm
	elif reverse(hh) >= mm:
		return reverse(hh) - mm
	else:
		return reverse(hh + 1) + 60 - mm
import sys
if sys.argv and sys.argv[-1] == 'test':
	assert main('12:21') == 0
	assert main('00:21') == 49
	assert main('05:51') == 250
	assert main('08:21') == 100
	assert main('15:51') == 0
	assert main('15:41') == 10
	assert main('12:22') == 69
	assert main('18:20') == 102
	assert main('23:22') == 10
	assert main('23:40') == 20
else:
	print(main(input()))


pal = input()
n1 = pal[0:2]
n2 = pal[3:5]
horas = 0
for i in range(500):
	if (n1 + n2)[::-1] == n1 + n2:
		break
	else:
		horas += 1
		n2 = str(int(n2) + 1)
		if len(n2) == 1:
			n2 = '0' + n2
		if n2 == '60':
			n2 = '00'
			n1 = str(int(n1) + 1)
			if len(n1) == 1:
				n1 = '0' + n1
			if n1 == '24':
				n1 = '00'
print(horas)


(h, m) = map(int, input().split(':'))
for i in range(24 * 60):
	s = str(h).zfill(2) + str(m).zfill(2)
	if s == s[::-1]:
		print(i)
		exit()
	m += 1
	h += m // 60
	m %= 60
	h %= 24


l = list()
for i in range(24):
	x = i * 10 % 100 + i * 10 // 100
	if x < 60:
		l.append(i * 60 + x)
(a, b) = map(int, input().split(':'))
t = a * 60 + b
answer = 24 * 60 - t
for e in l:
	if t <= e:
		answer = e - t
		break
print(answer)


t = input()
counter = 0
while True:
	if t[0] == t[4] and t[1] == t[3]:
		break
	if t[3:5] == '59':
		h = int(t[0:2])
		h += 1
		t = '%02d' % h + ':' + '00'
		if t[0:2] == '24':
			t = '00:00'
		counter += 1
		continue
	if t[3:5] != '59':
		m = int(t[3:5])
		m += 1
		t = t[0:2] + ':' + '%02d' % m
	counter += 1
print(counter)


import sys, math
from collections import deque
import random

def addOne(h, m):
	if m < 59:
		m += 1
		return (h, m)
	else:
		m = 0
		h = (h + 1) % 24
		return (h, m)

def isPalindrome(h, m):
	if h // 10 == m % 10 and h % 10 == m // 10:
		return True
	else:
		return False
ti = input().split(':')
h = int(ti[0])
m = int(ti[1])
cnt = 0
while 1 > 0:
	if isPalindrome(h, m):
		break
	(h, m) = addOne(h, m)
	cnt += 1
print(cnt)


def ok(h, m):
	if h // 10 == m % 10 and h % 10 == m // 10:
		return 1
	return 0
(h, m) = (int(x) for x in input().split(':'))
ans = 0
while not ok(h, m):
	ans = ans + 1
	m = m + 1
	if m == 60:
		h = h + 1
		m = 0
	if h == 24:
		h = 0
print(ans)


s = list(map(int, input().split(':')))
i = 0
while s[0] % 10 * 10 + s[0] // 10 != s[1]:
	i += 1
	s[1] += 1
	s[0] += s[1] // 60
	s[1] %= 60
	s[0] %= 24
print(i)


def is_pal(s):
	return s[0] == s[-1] and s[1] == s[-2]

def get_pal(h, m):
	if h < 10:
		h = '0' + str(h)
	else:
		h = str(h)
	if m < 10:
		m = '0' + str(m)
	else:
		m = str(m)
	return h + ':' + m
s = input()
if is_pal(s):
	print(0)
else:
	h = int(s[:2])
	m = int(s[3:])
	if h == 23 and m > 32:
		print(60 - m)
	else:
		out = 0
		while not is_pal(get_pal(h, m)):
			m += 1
			if m == 60:
				m = 0
				h += 1
			out += 1
		print(out)


(H, M) = map(int, input().split(':'))
for i in range(24 * 60):
	th = int((H + int((i + M) / 60)) % 24)
	tm = int((M + i) % 60)
	if int(th / 10) == tm % 10 and th % 10 == int(tm / 10):
		print(i)
		break


(h, m) = input().split(':')
if h == m[::-1]:
	print(0)
	exit()

def func(h):
	revh = h[::-1]
	if int(revh) > int(m):
		print(int(revh) - int(m))
		exit()
	intnh = int(h) + 1
	if intnh == 24:
		ans = 60 - int(m)
		print(ans)
		exit()
	if 6 <= intnh and intnh <= 9:
		intnh = 10
	elif 16 <= intnh and intnh <= 19:
		intnh = 20
	strnh = '{0:02d}'.format(intnh)
	ans = 60 - int(m) + int(strnh[::-1]) + (intnh - int(h) - 1) * 60
	print(ans)
	exit()
if h in ['00', '01', '02', '03', '04', '05', '10', '11', '12', '13', '14', '15', '20', '21', '22', '23']:
	func(h)
elif h in ['06', '07', '08', '09']:
	ans = 60 - int(m) + (9 - int(h)) * 60 + 1
	print(ans)
else:
	ans = 60 - int(m) + (19 - int(h)) * 60 + 2
	print(ans)


s = input()
sl = s.split(':')
cnt = 0
il = [0, 0]
for i in range(2):
	il[i] = int(sl[i])
while 1:
	sl[0] = str(il[0])
	sl[1] = str(il[1])
	sl[0] = sl[0].zfill(2)
	sl[1] = sl[1].zfill(2)
	if sl[0][::-1] == sl[1]:
		print(cnt)
		break
	cnt += 1
	il[1] = il[1] + 1
	if il[1] == 60:
		il[1] = 0
		il[0] += 1
	if il[0] == 24:
		il[0] = 0


(hh, mm) = [int(i) for i in input().split(':')]

def is_palindorme(hh, mm):
	if hh < 10:
		hh = '0' + str(hh)
	if mm < 10:
		mm = '0' + str(mm)
	hh = str(hh)
	mm = str(mm)
	if mm[1] + mm[0] + hh[1] + hh[0] == hh + mm:
		return True
	return False
ans = 0
while not is_palindorme(hh, mm):
	mm += 1
	if mm > 59:
		mm = mm - 60
		hh += 1
	if hh > 23:
		hh = 0
	ans += 1
print(ans)


(h, m) = input().split(':')
(h_i, m_i) = (int(h), int(m))
total = 0
while h != m[::-1]:
	m_i += 1
	if m_i == 60:
		h_i += 1
		h_i %= 24
		m_i = 0
	h = str(h_i).zfill(2)
	m = str(m_i).zfill(2)
	total += 1
print(total)


S = input()
l = [S[0], S[1], S[3], S[4]]
k = 0
while l[0] + l[1] != l[3] + l[2]:
	t = int(l[3])
	t = t + 1
	if t == 10:
		l[3] = '0'
		r = int(l[2])
		r = r + 1
		if r == 6:
			l[2] = '0'
			r = int(l[1])
			if l[0] == '2' and l[1] == '3':
				print(k + 1)
				exit()
			r = r + 1
			if r == 10:
				l[1] = '0'
				l[0] = str(int(l[0]) + 1)
			else:
				l[1] = str(int(l[1]) + 1)
		else:
			l[2] = str(r)
	else:
		l[3] = str(t)
	k = k + 1
print(k)


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

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

def rls():
	return list(input())

def pli(a):
	return ''.join(list(map(str, a)))
s = rls()
ans = 0
for i in range(1440):
	if s[0] == s[4] and s[1] == s[3]:
		print(ans)
		break
	else:
		ans += 1
		h = int(s[0] + s[1])
		m = int(s[3] + s[4])
		m += 1
		if m == 60:
			m = 0
			h += 1
			if h == 24:
				print(ans)
				break
		s[0] = str(h // 10)
		s[1] = str(h - int(s[0]) * 10)
		s[3] = str(m // 10)
		s[4] = str(m - int(s[3]) * 10)


def is_palindrome(time):
	return time == time[::-1]

def from_ints_to_time(hour, minute):
	result = ''
	if hour < 10:
		result += '0'
	result += str(hour)
	result += ':'
	if minute < 10:
		result += '0'
	result += str(minute)
	return result

def advance(hour, minute):
	(new_minute, new_hour) = (0, hour)
	new_minute = minute + 1
	if new_minute == 60:
		new_minute = 0
		new_hour = hour + 1
		if new_hour == 24:
			new_hour = 0
	return (new_hour, new_minute)

def main():
	(hour, minute) = [int(elem) for elem in input().split(':')]
	counter = 0
	while True:
		time = from_ints_to_time(hour, minute)
		if is_palindrome(time):
			break
		(hour, minute) = advance(hour, minute)
		counter += 1
	print(counter)
main()


a = [0, 70, 2 * 60 + 20, 3 * 60 + 30, 4 * 60 + 40, 5 * 60 + 50, 10 * 60 + 1, 11 * 60 + 11, 12 * 60 + 21, 13 * 60 + 31, 14 * 60 + 41, 15 * 60 + 51, 20 * 60 + 2, 21 * 60 + 12, 22 * 60 + 22, 23 * 60 + 32, 24 * 60]
(h, m) = map(int, input().split(':'))
t = h * 60 + m
for x in a:
	if x - t >= 0:
		print(x - t)
		break


a = input()
t1 = a[0:2]
t2 = a[3:5]
step = 0
h = int(t1)
m = int(t2)
aim = int(t1[1] + t1[0])
ans = 0
if aim >= m and aim <= 59:
	print(aim - m)
else:
	ans += 60
	h += 1
	if h == 24:
		h = 0
	if h >= 10:
		t1 = str(h)
	else:
		t1 = '0' + str(h)
	aim = int(t1[1] + t1[0])
	while not aim <= 59:
		ans += 60
		h += 1
		if h == 24:
			h = 0
		if h >= 10:
			t1 = str(h)
		else:
			t1 = '0' + str(h)
		aim = int(t1[1] + t1[0])
	print(aim + ans - m)


n = ''.join(input().split(':'))
cnt = 0

def H(time):
	hour = int(time[0])
	minute = int(time[1])
	if minute != 59:
		minute += 1
	elif minute == 59:
		minute = 0
		hour += 1
	time = ''.join([str(hour).zfill(2), str(minute).zfill(2)])
	return time
while n != n[::-1]:
	if n == '2359':
		cnt += 1
		break
	n1 = [n[0:2]]
	n2 = [n[2:]]
	time = n1 + n2
	n = H(time)
	cnt += 1
print(cnt)


(h, m) = input().split(':')
ans = 0
while h != m[1] + m[0]:
	m = str(int(m) + 1)
	h = str(int(m) // 60 + int(h))
	h = str(int(h) % 24)
	m = str(int(m) % 60)
	m = max(0, 2 - len(m)) * '0' + m
	h = max(0, 2 - len(h)) * '0' + h
	ans += 1
print(ans)


rawtime = input()
hours = int(rawtime[0:2])
minutes = int(rawtime[3:5])

def isPal(s):
	a = list(s)
	a.reverse()
	return list(s) == a

def formatTime(hours, minutes):
	time = ''
	if hours < 10:
		time += '0'
	time += str(hours)
	time += ':'
	if minutes < 10:
		time += '0'
	time += str(minutes)
	return time
count = 0
while not isPal(formatTime(hours, minutes)):
	count += 1
	if minutes < 59:
		minutes += 1
	elif hours < 23:
		hours += 1
		minutes = 0
	else:
		hours = 0
		minutes = 0
print(count)


Count = 0
(Hour, Min) = list(map(int, input().split(':')))
Count = 0
while str(Hour).rjust(2, '0') != ''.join(reversed(str(Min).rjust(2, '0'))):
	Min += 1
	if Min == 60:
		Hour += 1
		Min = 0
	if Hour == 24:
		Hour = 0
	Count += 1
print(Count)


string = input()
a = int(string[0]) * 10 + int(string[1])
b = int(string[3]) * 10 + int(string[4])

def PalyndromCheck(a, b):
	alpha = str(a)
	beta = str(b)
	if len(alpha) == 1:
		alpha = '0' + alpha
	if len(beta) == 1:
		beta = '0' + beta
	if alpha[0] == beta[1] and beta[0] == alpha[1]:
		return True
	else:
		return False
k = 0
while PalyndromCheck(a, b) == False:
	b = b + 1
	k = k + 1
	if b == 60:
		b = 0
		a = a + 1
	if a == 24:
		a = 0
print(k)


s = input()
(a, b) = (int(s[0]), int(s[1]))
(c, d) = (int(s[3]), int(s[4]))
x = a * 10 + b * 1
y = c * 10 + d * 1
if x == 5 and y > 50:
	print(60 - y + 60 * (10 - (x + 1)) + 1)
elif x == 15 and y > 51:
	print(60 - y + 60 * (20 - (x + 1)) + 2)
elif x > 5 and x < 10:
	print(60 - y + 60 * (10 - (x + 1)) + 1)
elif x > 15 and x < 20:
	print(60 - y + 60 * (20 - (x + 1)) + 2)
elif x == 23 and y > 32:
	print(60 - y)
elif x == 23 and y <= 32:
	print(32 - y)
else:
	x1 = b * 10 + a * 1
	if x1 >= y:
		print(x1 - y)
	else:
		print(x1 + 10 + (60 - y))


def ispalin(hh, mm):
	if hh == mm[::-1]:
		return True
	else:
		return False
s = input()
hh = s[:2]
mm = s[3:]
i = 0
while not ispalin(hh, mm):
	if int(mm) < 59:
		if mm == '09':
			mm = '10'
		elif mm[0] == '0':
			mm = '0' + str(int(mm) + 1)
		else:
			mm = str(int(mm) + 1)
	elif int(mm) == 59:
		mm = '00'
		if int(hh) < 23:
			if hh == '09':
				hh = '10'
			elif hh[0] == '0':
				hh = '0' + str(int(hh) + 1)
			else:
				hh = str(int(hh) + 1)
		elif int(hh) == 23:
			hh = '00'
	i += 1
print(i)


def time_to_string(tt):
	if tt < 10:
		return '0{}'.format(str(tt))
	else:
		return str(tt)
(hh, mm) = (int(x) for x in input().split(':'))
ans = 0
while not time_to_string(mm)[::-1] == time_to_string(hh):
	mm += 1
	ans += 1
	if mm == 60:
		mm = 0
		hh += 1
		if hh == 24:
			hh = 0
print(ans)


(hh, mm) = map(int, input().split(':'))
num = 0

def check(x, y):
	x = str(x)
	y = str(y)
	if len(x) == 1:
		x = '0' + x
	if len(y) == 1:
		y = '0' + y
	return x[::-1] == y
while True:
	if check(hh, mm):
		break
	mm += 1
	if mm >= 60:
		hh += 1
		mm = 0
		if hh >= 24:
			hh = 0
	num += 1
print(num)


time = input()
hour = int(time[:2])
minute = int(time[-2:])
h1 = hour % 10
m1 = minute % 10
h2 = (hour - h1) % 100 / 10
m2 = (minute - m1) % 100 / 10
k = 0
while h2 != m1 or h1 != m2:
	minute += 1
	if minute == 60:
		hour += 1
		minute = 0
	if hour == 24:
		hour = 0
	h1 = hour % 10
	m1 = minute % 10
	h2 = (hour - h1) % 100 / 10
	m2 = (minute - m1) % 100 / 10
	k += 1
print(k)


def convert(t):
	(x, y) = t
	return x * 60 + y

def dist(u, v):
	if v < u:
		v += 1440
	return v - u

def f(x):
	x = str(x)
	while len(x) < 2:
		x = '0' + x
	if int(x[::-1]) >= 60:
		return None
	return 60 * int(x) + int(x[::-1])
(hh, mm) = map(int, input().split(':'))
val = convert((hh, mm))
can = [i for i in range(24)]
can = list(map(f, can))
can = list(filter(lambda x: x != None, can))
print(min(map(lambda x: dist(val, x), can)))


(a, b) = map(str, input().split(':'))
k = 0
while True:
	if a == b[::-1]:
		print(k)
		break
	else:
		k += 1
		if int(b) + 1 == 60:
			b = '00'
			if int(a) + 1 == 24:
				a = '00'
			elif int(a) + 1 < 10:
				a = '0' + repr(int(a) + 1)
			else:
				a = repr(int(a) + 1)
		elif int(b) + 1 < 10:
			b = '0' + repr(int(b) + 1)
		else:
			b = repr(int(b) + 1)


from datetime import datetime, timedelta
s = input()
dt = datetime.strptime(s, '%H:%M')
ans = 0
while dt.strftime('%H:%M') != dt.strftime('%H:%M')[::-1]:
	dt += timedelta(minutes=1)
	ans += 1
print(ans)


from datetime import timedelta as time
(x, y) = map(int, input().split(':'))
base = time(hours=x, minutes=y)
start = base
mm = time(minutes=1)
if x == 23 and y == 59:
	print(1)
else:
	x = False
	while 1:
		if base == time(hours=23, minutes=59):
			x = True
			break
		t = str(base)
		t = t[:-3]
		t = t.rjust(5, '0')
		if t == t[::-1]:
			break
		base += mm
	diff = list(map(int, str(base - start).split(':')))
	diff = diff[0] * 60 + diff[1]
	if x:
		diff += 1
	print(diff)


import sys
time = sys.stdin.readline()
minutesString = time[3] + time[4]
minutes = int(minutesString)
hoursString = time[0] + time[1]
hours = int(hoursString)
hoursOriginal = hours
minutesOriginal = minutes
while not (hours % 10 == minutes // 10 and hours // 10 == minutes % 10):
	minutes = minutes + 1
	if minutes == 60:
		minutes = 0
		hours = hours + 1
	if hours == 24:
		hours = 0
minutesElapsed = (hours - hoursOriginal) * 60 + (minutes - minutesOriginal)
if minutesElapsed < 0:
	minutesElapsed = minutesElapsed + 24 * 60
print(minutesElapsed)


(h, m) = map(int, input().split(':'))
c = 0
if h < 10 and m < 10:
	s = '0' + str(h) + ':' + '0' + str(m)
elif h < 10 and m >= 10:
	s = '0' + str(h) + ':' + str(m)
elif h >= 10 and m < 10:
	s = str(h) + ':' + '0' + str(m)
else:
	s = str(h) + ':' + str(m)
while s != s[::-1]:
	m += 1
	h += m // 60
	m = m % 60
	h = h % 24
	if h < 10 and m < 10:
		s = '0' + str(h) + ':' + '0' + str(m)
	elif h < 10 and m >= 10:
		s = '0' + str(h) + ':' + str(m)
	elif h >= 10 and m < 10:
		s = str(h) + ':' + '0' + str(m)
	else:
		s = str(h) + ':' + str(m)
	c += 1
print(c)


s = str(input())
h = s.split(':')[0]
m = s.split(':')[1]
m = int(m) - 1
count = -1
while 1:
	m = int(m) + 1
	count = count + 1
	if m == 60:
		m = 0
		h = int(h) + 1
	if h == 24:
		h = 0
	h = '00' + str(h)
	m = '00' + str(m)
	if h[-2:] == m[-2:][::-1]:
		break
print(count)


from sys import stdin
import math
a = stdin.readline()
A = int(a[0] + a[1])
B = int(a[3] + a[4])
count = 0
while True:
	if math.floor(B / 10) + B % 10 * 10 == A:
		print(count)
		break
	else:
		if B == 59:
			B = 0
			if A < 23:
				A += 1
			else:
				A = 0
		else:
			B += 1
		count += 1


def f():
	global a, b
	if a == '23' and b == '59':
		a = '00'
		b = '00'
		return
	if b == '59':
		a = str(int(a) + 1)
		if len(a) == 1:
			a = '0' + a
		b = '00'
		return
	b = str(int(b) + 1)
	if len(b) == 1:
		b = '0' + b

def f1(s):
	res = ''
	for i in range(len(s)):
		res += s[len(s) - i - 1]
	return res
s = input()
a = s[:2]
b = s[3:]
ans = 0
while a + b != f1(b) + f1(a):
	f()
	ans += 1
print(ans)


(h, m) = map(int, input().split(':'))
i = 0
while h // 10 + h % 10 * 10 != m:
	(m, i) = (m + 1, i + 1)
	if m == 60:
		(h, m) = (h + 1 if h < 23 else 0, 0)
print(i)


def main():
	(x, y) = input().split(':')
	ans = 0
	if int(x) > 5 and int(x) < 10:
		ans = 61 - int(y) + (9 - int(x)) * 60
	elif int(x) > 15 and int(x) < 20:
		ans = 62 - int(y) + (19 - int(x)) * 60
	elif x[::-1] == '50':
		if int(x[::-1]) >= int(y):
			ans = int(x[::-1]) - int(y)
		else:
			ans = 61 - int(y) + (9 - int(x)) * 60
	elif x == '15':
		if int(x[::-1]) >= int(y):
			ans = int(x[::-1]) - int(y)
		else:
			ans = 62 - int(y) + (19 - int(x)) * 60
	elif x == '23':
		if int(x[::-1]) >= int(y):
			ans = int(x[::-1]) - int(y)
		else:
			ans = 60 - int(y)
	elif int(x[::-1]) >= int(y):
		ans = int(x[::-1]) - int(y)
	else:
		x = x[0] + str(int(x[1]) + 1)
		ans = 60 - int(y) + int(x[::-1])
	print(ans)
main()


(h, m) = map(int, input().split(':'))
dur = True
ans = -1
while dur == True:
	dur = False if h // 10 == m % 10 and h % 10 == m // 10 else True
	m = 0 if m + 1 == 60 else m + 1
	h = (h + 1) % 24 if m == 0 else h
	ans += 1
print(ans)


a = lambda h, m, i: ((h + (m + i) // 60) % 24, (m + i) % 60)
s = lambda h, m: '%02d:%02d' % (h, m)
p = lambda s: s == s[::-1]
(h, m) = (int(v) for v in input().split(':'))
print(next((i for i in range(999) if p(s(*a(h, m, i))))))


from math import gcd, ceil
from collections import defaultdict as dd

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

def inin():
	return int(input())

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

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su
(hh, mm) = input().split(':')
hh = int(hh)
mm = int(mm)
cnt = 0
while hh % 10 != mm // 10 or mm % 10 != hh // 10:
	mm += 1
	cnt += 1
	if mm == 60:
		mm = 0
		hh += 1
		hh %= 24
print(cnt)


import sys
(h, m) = map(str, sys.stdin.readline().split(':'))
ans = 0
while h.strip() != m.strip()[::-1]:
	h = int(h)
	m = int(m)
	m += 1
	ans += 1
	if m == 60:
		m = 0
		h += 1
		if h == 24:
			h = 0
	if m < 10:
		m = '0' + str(m)
	else:
		m = str(m)
	if h < 10:
		h = '0' + str(h)
	else:
		h = str(h)
print(ans)


def check(hour, minute):
	if hour // 10 == minute % 10:
		if hour % 10 == minute // 10:
			return True
	return False
[hour, minute] = list(map(int, input().split(':')))
[inh, inm] = [hour, minute]
step = 0
while step <= 1440:
	if minute == 60:
		minute = 0
		hour += 1
	if hour == 24:
		hour = 0
	if check(hour, minute):
		print(step)
		break
	minute += 1
	step += 1


(hh, mm) = input().split(':')
(h0, m0) = map(int, (hh, mm))
h = h0
if mm > hh[::-1]:
	h += 1
if h % 10 > 5:
	h = (h // 10 + 1) * 10
m = int(str(h % 24).zfill(2)[::-1])
print(60 * (h - h0) + m - m0)


import re
import os
x = input()
h = int(x[0:2])
m = int(x[3:5])

def check(str):
	L = len(str)
	for k in range(int(L / 2)):
		if str[k] != str[L - 1 - k]:
			return 0
	return 1
for t in range(60 * 24):
	if check(str(h).zfill(2) + str(m).zfill(2)):
		print(t)
		break
	m += 1
	if m >= 60:
		h += 1
		m -= 60
		if h > 23:
			h = 0


class soat:

	def __init__(self, s, d):
		self.soat = s
		self.daq = d
		self.badaq = s * 60 + d

	def __add__(self, diga):
		if type(diga) == int:
			(s, d) = divmod(diga, 60)
			v1d = v1.daq
			v1s = v1.soat
			v1d += d
			if v1d > 59:
				v1s += 1
				v1d -= 60
			v1s = (v1s + s) % 24
			return soat(v1s, v1d)
		elif type(diga) == soat:
			s = self.soat + diga.soat
			d = self.daq + diga.daq
			if d > 59:
				s += 1
				d -= 60
			s = s % 24
			return soat(s, d)

	def __sub__(self, diga):
		s = self.soat - diga.soat
		d = self.daq - diga.daq
		if d < 0:
			d += 60
			s -= 1
		s = s % 24
		return soat(s, d)

	def __str__(self):
		s = str(self.soat)
		d = str(self.daq)
		s = '0' * (2 - len(s)) + s
		d = '0' * (2 - len(d)) + d
		return s + ':' + d

	def __eq__(self, diga):
		return self.soat == diga.soat and self.daq == diga.daq

	def __ge__(self, other):
		return self.soat >= other.soat and self.daq >= other.daq

	def __gt__(self, other):
		if self.soat == other.soat:
			return self.daq > other.daq
		return self.soat > other.soat
(s, d) = map(int, input().split(':'))
V = soat(s, d)
palindromho = []
for i in range(0, 24):
	if i < 10:
		if i % 10 < 6:
			palindromho.append(soat(i, i * 10))
	elif i % 10 < 6:
		palindromho.append(soat(i, int(str(i)[-1::-1])))
M = []
for vaqt in palindromho:
	M.append((vaqt - V).badaq)
print(min(M))


line = input()
line = line.split(':')
hh = int(line[0])
mm = int(line[1])
pal = hh % 10 * 10 + hh // 10
if hh == 0 and mm != 0:
	ans = 60 - mm + 10
elif pal >= mm and pal < 60:
	ans = pal - mm
elif hh % 10 >= 5:
	ans = 60 - mm + (10 - (hh % 10 + 1)) * 60 + hh // 10 + 1
elif pal <= mm:
	ans = 60 - mm
	if hh != 23:
		ans = pal + ans + 10
print(ans)


IN = input()
(a, b) = IN.split(':')
OUT = ''
pali_H = ['00', '01', '02', '03', '04', '05', '10', '11', '12', '13', '14', '15', '20', '21', '22', '23', '06', '07', '08', '09', '15', '16', '17', '18', '19']
pali_M = ['00', '10', '20', '30', '40', '50', '01', '11', '21', '31', '41', '51', '02', '12', '22', '32', '-1', '-1', '-1', '-1', '-1', '-1', '-1', '-1', '-1']
if b == pali_M[pali_H.index(a)]:
	OUT = '0'
elif b < pali_M[pali_H.index(a)]:
	OUT = str(int(a[::-1]) - int(b))
else:
	a = str(int(a) + 1)
	if len(a) == 1:
		a = '0' + a
	if a == '24':
		OUT = str(60 - int(b))
	elif pali_M[pali_H.index(a)] == '-1':
		a1 = a
		while pali_M[pali_H.index(a)] == '-1':
			a = str(int(a) + 1)
			if len(a) == 1:
				a = '0' + a
		OUT = str((1 + int(a) - int(a1)) * 60 - int(b) + int(a[::-1]))
	else:
		OUT = str(60 + int(a[::-1]) - int(b))
print(OUT)


def palindrome(hour, minute):
	if hour == minute[::-1]:
		return True
	return False
time = input().split(':')
(h, m) = (time[0], time[1])
(hh, mm) = (int(time[0]), int(time[1]))
iterated = 0
while not palindrome(h, m):
	mm = mm + 1
	if mm >= 60:
		mm = 0
		hh = hh + 1
	if hh >= 24:
		hh = 0
	if hh < 10:
		h = '0' + str(hh)
	else:
		h = str(hh)
	if mm < 10:
		m = '0' + str(mm)
	else:
		m = str(mm)
	iterated = iterated + 1
print(iterated)


def f(s):
	return s == s[-1::-1]
(a, b) = input().split(':')
(p, q) = (int(a), int(b))
c = 0
while not f(a + b):
	temp = (q + 1) // 60
	q = (q + 1) % 60
	p = (p + temp) % 24
	c += 1
	(a, b) = (str(p), str(q))
	if len(a) == 1:
		a = '0' + a
	if len(b) == 1:
		b = '0' + b
print(c)


(hh, mm) = map(int, input().split(':'))
ans = 0
while hh % 10 != mm // 10 or hh // 10 != mm % 10:
	mm += 1
	if mm == 60:
		mm = 0
		hh += 1
		if hh == 24:
			hh = 0
	ans += 1
print(ans)


date = input()
hours = int(date[0:2])
h_1 = int(date[0:1])
h_2 = int(date[1:2])
m = int(date[3:5])
k = 0
while h_2 * 10 + h_1 != m:
	m = m + 1
	k = k + 1
	if m % 60 == 0:
		m = 0
		hours = (hours + 1) % 24
		h_1 = int(hours / 10)
		h_2 = hours % 10
print(k)


def b(h, m):
	s = '%02d:%02d' % (h, m)
	return s == s[::-1]
(h, m) = map(int, input().split(':'))
ans = 0
while not b(h, m):
	ans += 1
	m += 1
	if m == 60:
		m = 0
		h = (h + 1) % 24
print(ans)


from datetime import datetime
t = datetime.strptime(input().rstrip(), '%H:%M')
pal = [j + ':' + j[::-1] for j in [('0' if i < 10 else '') + str(i) for i in [0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23]]]
min_diff = 3600 * 24
for time in pal:
	T = datetime.strptime(time, '%H:%M')
	diff = (T - t).seconds
	min_diff = min(diff, min_diff)
print(min_diff // 60)


N = input()
c = 0
m = 1

def EsPalindrome(N):
	N = N.split(':')
	H = N[0]
	M = N[1]
	return H[0] == M[1] and H[1] == M[0]

def AumentarMinutos(N, m):
	N = N.split(':')
	H = int(N[0])
	M = int(N[1])
	M = M + m + H * 60
	H = str(M // 60)
	if int(H) >= 24:
		H = '0'
	M = str(M % 60)
	if int(H) < 10:
		H = '0' + H
	if int(M) < 10:
		M = '0' + M
	return H + ':' + M
while not EsPalindrome(N):
	c += 1
	N = AumentarMinutos(N, m)
print(c)


line = input().split(':')
(hrs, mins) = line
done = False
t = 0
while not done:
	p_mins = mins[::-1]
	i_mins = int(mins)
	p_hrs = int(hrs[::-1])
	i_hrs = int(hrs)
	if (i_hrs in range(0, 6) or i_hrs in range(10, 16) or i_hrs in range(20, 24)) and i_mins <= p_hrs:
		done = True
		t += p_hrs - i_mins
	else:
		t += 60 - i_mins
		hrs = '0' + str((i_hrs + 1) % 24)
		hrs = hrs[-2:]
		mins = '00'
print(t)


import sys
import math
import itertools
import collections

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

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

def wr(arr):
	return ''.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber

def z(n):
	if n < 10:
		return '0' + str(n)
	else:
		return str(n)
(hh, mm) = map(int, input().split(':'))
ans = 0
while z(hh) != revn(z(mm)):
	if mm + 1 == 60:
		if hh == 23:
			hh = 0
		else:
			hh += 1
		mm = 0
	else:
		mm += 1
	ans += 1
print(ans)


import sys

def solve():
	s = input()
	m = timetomin(s)
	ans = 0
	while not is_pali(mintotime(m)):
		m += 1
		m %= 24 * 60
		ans += 1
	print(ans)

def is_pali(s):
	return s == s[::-1]

def mintotime(m):
	return '{:02d}:{:02d}'.format(m // 60, m % 60)

def timetomin(s):
	(h, m) = map(int, s.split(':'))
	return h * 60 + m
solve()


(hh, mm) = [str(x) for x in input().split(':')]
ih = int(hh)
im = int(mm)
cnt = 0
while True:
	sh = str(ih)
	sm = str(im)
	if len(sh) == 1:
		sh = '0' + sh
	if len(sm) == 1:
		sm = '0' + sm
	if sh == sm[::-1]:
		print(cnt)
		break
	im += 1
	if im >= 60:
		ih += 1
		im = 0
	if ih >= 24:
		ih = 0
	cnt += 1


(h, m) = map(int, input().split(':'))
a = h * 60 + m
lis = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412, 0]
if a > 1412:
	print(1440 - a)
else:
	ans = 10000
	for x in lis:
		if x < a:
			continue
		elif x - a < ans:
			ans = x - a
	print(ans)


(h, m) = map(int, input().split(':'))
c = 0
while 1:
	r = m % 10 * 10 + m // 10
	if r == h:
		print(c)
		break
	c += 1
	m += 1
	if m == 60:
		m = 0
		h += 1
	if h == 24:
		h = 0


(s, i) = (list(map(int, input().split(':'))), 0)
(h, m) = (s[0], s[1])
while True:
	(sh, sm) = (str(h), str(m))
	if len(sh) == 1:
		sh = '0' + str(h)
	if len(sm) == 1:
		sm = '0' + str(m)
	if sh[0] == sm[1] and sh[1] == sm[0]:
		print(i)
		break
	else:
		i += 1
		m += 1
		if m == 60:
			h += 1
			m = 0
			if h == 24:
				h = 0


(h, m) = map(int, input().split(':'))

def increment():
	nonlocal m, h
	m += 1
	h += m // 60
	m %= 60
	h %= 24

def reverse(num):
	return num % 10 * 10 + num // 10
ans = 0
while h != reverse(m):
	increment()
	ans += 1
print(ans)


inp = input().replace(':', '')
l = ['0000', '0110', '0220', '0330', '0440', '0550', '1001', '1111', '1221', '1331', '1441', '1551', '2002', '2112', '2222', '2332']
ans = 0
if inp in l:
	ans = 0
else:
	counter = 0
	while counter < len(l) and l[counter] < inp:
		counter += 1
	(h, m) = (int(inp[0:2]), int(inp[-2:]))
	s = l[counter] if counter < len(l) else '2400'
	(hi, mi) = (int(s[0:2]), int(s[-2:]))
	if hi - h > 0:
		if mi > m:
			ans = (hi - h) * 60 + mi - m
		else:
			ans = (hi - h - 1) * 60 + mi + 60 - m
	else:
		ans = mi - m
print(ans)


s = input()
(h, m) = map(int, s.split(':'))
for i in range(60 * 24):
	hh = '0' + str(h) if h < 10 else str(h)
	mm = '0' + str(m) if m < 10 else str(m)
	if hh[::-1] == mm:
		print(i)
		break
	if m < 59:
		m += 1
	else:
		h = (h + 1) % 24
		m = 0


(h, m) = input().split(':')
pos_hours = list(range(0, 6)) + list(range(10, 16)) + list(range(20, 25))
if int(h[1] + h[0]) == int(m):
	print(0)
elif int(h[1] + h[0]) > int(m) and int(h) in pos_hours:
	print(int(h[1] + h[0]) - int(m))
else:
	i = 0
	while pos_hours[i] <= int(h):
		i += 1
	if pos_hours[i] == 24:
		i = 0
	next_hour = '{:0>2}'.format(pos_hours[i])
	minutes = 60 - int(m) + int(next_hour[1] + next_hour[0]) + (int(next_hour) - int(h) - 1) * 60
	if int(next_hour) - int(h) - 1 < 0:
		minutes += 1440
	print(minutes)


(a, b) = map(int, input().split(':'))
ans = 0
while True:
	(sa, sb) = (str(a), str(b))
	if a // 10 < 1:
		sa = '0' + sa
	if b // 10 < 1:
		sb = '0' + sb
	if sa[0] == sb[1] and sa[1] == sb[0]:
		print(ans)
		exit()
	b += 1
	ans += 1
	if b > 59:
		a += 1
		b = 0
	if a > 23:
		a = 0


(h, m) = map(int, input().split(':'))
m += h * 60
r = 0
while f'{m // 60:02}' != f'{m % 60:02}'[::-1]:
	m = (m + 1) % 1440
	r += 1
print(r)


(hh, mm) = input().split(':')
(h0, m0) = map(int, (hh, mm))
h = h0
if mm > hh[::-1]:
	h += 1
if h % 10 > 5:
	h = (h // 10 + 1) * 10
m = 0 if h == 24 else h % 10 * 10 + h // 10
print(60 * (h - h0) + m - m0)


A = input()
h = A[0] + A[1]
m = A[3] + A[4]
z = h + m
if z == z[::-1]:
	print(0)
else:
	c = 0
	while z != z[::-1]:
		im = int(m)
		ih = int(h)
		if im < 59:
			m = str(im + 1)
			if int(m) < 10:
				m = '0' + m
			c = c + 1
		elif im >= 59:
			h = str(ih + 1)
			if int(h) < 10:
				h = '0' + h
			m = str(0)
			if int(m) < 10:
				m = '0' + m
			c = c + 1
		if int(h) > 23:
			h = str(0)
			if int(h) < 10:
				h = '0' + h
		z = str(h) + str(m)
	print(c)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def check(s):
	(a, b) = s.split(':')
	x = a + b
	y = x[-1::-1]
	return x == y
s = input().strip()
(p, q) = s.split(':')
ans = 0
while not check(p + ':' + q):
	x = int(q) + 1
	x %= 60
	y = int(p)
	if x == 0:
		y += 1
		y %= 24
	if y < 10:
		p = '0' + str(y)
	else:
		p = str(y)
	if x < 10:
		q = '0' + str(x)
	else:
		q = str(x)
	ans += 1
print(ans)


import sys
import math
import bisect

def solve(s):
	h = int(s[0:2])
	m = int(s[3:5])
	cnt = 0
	while True:
		s = str(h).zfill(2) + ':' + str(m).zfill(2)
		if s == s[::-1]:
			return cnt
		m += 1
		if m == 60:
			m -= 60
			h += 1
		if h == 24:
			h = 0
		cnt += 1
	return -1

def main():
	s = input()
	print(solve(s))
main()


time = str(input())
h = int(time[0] + time[1])
hs = time[0] + time[1]
m = int(time[3] + time[4])
ms = time[3] + time[4]
rh = int(time[1] + time[0])
newh = 0
newm = 0
newhs = ''
newms = ''
dif = 0
if rh > m:
	if rh >= 60 and rh <= 90 and (h < 10):
		newh = 10
		newhs = '10'
		newms = '01'
		dif = 60 * (10 - h) + 1 - m
	elif rh >= 61 and rh <= 91 and (h > 15):
		newh = 20
		newhs = '20'
		newms = '02'
		dif = 60 * (20 - h) + 2 - m
	else:
		dif = rh - m
elif rh < m:
	newh = (h + 1) % 24
	newhs = str(newh)
	if len(newhs) < 2:
		newhs = '0' + newhs
	newms = newhs[1] + newhs[0]
	newm = int(newms)
	dif = 60 - m
	dif += newm
	if rh == 50 and m > 50:
		newh = 10
		newhs = '10'
		newms = '01'
		dif = 60 * (10 - h) + 1 - m
	if rh >= 51 and rh <= 91:
		newh = 20
		newhs = '20'
		newms = '02'
		dif = 60 * (20 - h) + 2 - m
print(dif)


a = input()
k = 0
hours = int(a[0:2])
minuts = int(a[3:5])
a = str(hours)
if len(a) == 1:
	a = '0' + a
b = str(minuts)
if len(b) == 1:
	b = '0' + b
c = a + b
while c != c[::-1]:
	minuts = minuts + 1
	if minuts == 60:
		minuts = 0
		hours = hours + 1
	if hours == 24:
		hours = 0
	a = str(hours)
	b = str(minuts)
	if len(a) == 1:
		a = '0' + a
	if len(b) == 1:
		b = '0' + b
	c = a + b
	k = k + 1
print(k)


def isPalindrome(h, m):
	if h[0] == m[1] and h[1] == m[0]:
		return True
	return False
s = input()
(hi, mi) = list(map(int, s.split(':')))
(h, m) = (str(hi), str(mi))
if len(h) == 1:
	h = '0' + h
if len(m) == 1:
	m = '0' + m
i = 0
while not isPalindrome(h, m):
	mi += 1
	if mi == 60:
		hi += 1
		mi = 0
	if hi == 24:
		hi = 0
	(h, m) = (str(hi), str(mi))
	if len(h) == 1:
		h = '0' + h
	if len(m) == 1:
		m = '0' + m
	i += 1
print(i)


(h, m) = map(int, input().split(':'))
i = 0
while h // 10 + h % 10 * 10 - m:
	(h, m, i) = ((h + m // 59) % 24, (m + 1) % 60, i + 1)
print(i)


(h, m) = list(input().split(':'))
mins = 0
r = 0
while r == 0:
	h1 = int(h[0])
	h2 = int(h[1])
	m1 = int(m[0])
	m2 = int(m[1])
	if h1 == m2 and h2 == m1:
		r = 1
		continue
	else:
		mins += 1
		if m == '59':
			m = '00'
			if h == '23':
				h = '00'
			else:
				h = str(int(h) + 1)
				if len(h) == 1:
					h = '0' + h
		else:
			m = str(int(m) + 1)
			if len(m) == 1:
				m = '0' + m
print(mins)


import sys

def main():
	s = sys.stdin.readline().rstrip()
	(h, m) = s.split(':')
	if h[1] in ('0', '1', '2', '3', '4', '5'):
		midminute = h[1] + h[0]
		if m <= midminute:
			(hnext, mnext) = (h, midminute)
		elif h == '05':
			(hnext, mnext) = ('10', '01')
		elif h == '15':
			(hnext, mnext) = ('20', '02')
		elif h == '23':
			(hnext, mnext) = ('00', '00')
		else:
			hnext = '{:02d}'.format(int(h) + 1)
			mnext = hnext[1] + hnext[0]
	elif h[0] == '0':
		(hnext, mnext) = ('10', '01')
	elif h[0] == '1':
		(hnext, mnext) = ('20', '02')
	ih = int(h)
	im = int(m)
	ihnext = int(hnext)
	imnext = int(mnext)
	if ihnext == 0 and ih > 0:
		ihnext = 24
	result = (ihnext - ih) * 60 + (imnext - im)
	sys.stdout.write(str(result) + '\n')
main()


(h, m) = map(int, input().split(':'))
c = 0
do = True
(hs, ms) = (str(h), str(m))
if len(hs) == 1:
	hs = '0' + hs
if len(ms) == 1:
	ms = '0' + ms
if hs == ms[::-1]:
	print(c)
else:
	while do:
		m += 1
		c += 1
		if m == 60:
			h += 1
			m = 0
		if h == 24:
			h = 0
		(hs, ms) = (str(h), str(m))
		if len(hs) == 1:
			hs = '0' + hs
		if len(ms) == 1:
			ms = '0' + ms
		if hs == ms[::-1]:
			print(c)
			break


from sys import stdin

def time(x, c):
	c += 1
	x = str(x)
	while len(x) != 4:
		x = '0' + x
	y = x[::-1]
	return (x, y, c)

def main():
	x = stdin.readline().strip().split(':')
	x = ''.join(x)
	y = x[::-1]
	c = 0
	if x == y:
		print('0')
	else:
		while True:
			x = int(x)
			if x == 2359:
				x = 0
				(x, y, c) = time(x, c)
				if x == y:
					print(c)
					break
			elif x % 100 == 59:
				x -= 59
				x += 100
				(x, y, c) = time(x, c)
				if x == y:
					print(c)
					break
			else:
				x += 1
				(x, y, c) = time(x, c)
				if x == y:
					print(c)
					break
main()


a = input()
i = 0
m = int(a[-2:])
h = int(a[:2])
while a != a[::-1]:
	m += 1
	h += m // 60
	m = m % 60
	h = h % 24
	a = str(h).zfill(2) + ':' + str(m).zfill(2)
	i += 1
print(i)


(n, k) = map(int, input().split(':'))
ans = 0
while True:
	rk = int(str(k)[::-1])
	if len(str(k)) == 1:
		rk = int(str(k) + '0')
	if rk == n:
		break
	elif k < 59:
		k += 1
	elif k == 59:
		k = 0
		if n < 23:
			n += 1
		else:
			n = 0
	ans += 1
print(ans)


(hh, mm) = input().split(':')
hr = int(hh[::-1])
(hh, mm) = (int(hh), int(mm))
if mm <= hr and hr < 60:
	print(hr - mm)
	exit()
tm = 60 - mm
mm = 0
hh = (hh + 1) % 24
while hh % 10 >= 6:
	hh = (hh + 1) % 24
	tm += 60
print(tm + hh % 10 * 10 + hh // 10)


time = input()
time = time[0] + time[1] + time[3] + time[4]
flag = True
c = 0
while flag and time != '0000':
	if time == time[::-1]:
		flag = False
		break
	a = int(time[:2])
	b = int(time[2:])
	b += 1
	c += 1
	if b >= 60:
		b = 0
		a += 1
	if a >= 24:
		a = 0
	if a < 10:
		a = '0' + str(a)
	else:
		a = str(a)
	if b < 10:
		b = '0' + str(b)
	else:
		b = str(b)
	time = a + b
print(c)


def converttos(hr, mn):
	hs = str(hr)
	ms = str(mn)
	if len(hs) == 1:
		hs = '0' + hs
	if len(ms) == 1:
		ms = '0' + ms
	return hs + ':' + ms

def ispal(s):
	if len(s) % 2 == 1:
		s1 = s.split(s[int(len(s) / 2)])[0]
		s2 = s.split(s[int(len(s) / 2)])[1]
		if s1 == s2[::-1]:
			return True
		else:
			return False
	else:
		(s1, s2) = (s[:int(len(s) / 2)], s[int(len(s) / 2):])
		if s1 == s2[::-1]:
			return True
		else:
			return False

def main():
	s = input()
	hr = int(s.split(':')[0])
	mn = int(s.split(':')[1])
	if ispal(s):
		print(0)
		return
	i = 0
	while True:
		i += 1
		mn += 1
		if mn >= 60:
			mn = 0
			hr += 1
			if hr >= 24:
				hr = 0
		news = converttos(hr, mn)
		if ispal(news):
			print(i)
			break
main()


def isP(h, m):
	return ''.join(reversed(h)) == m

def incH(h):
	h = int(h) + 1
	if h == 24:
		h = 0
	h = str(h)
	if len(h) == 1:
		h = '0' + h
	return h

def incM(h, m):
	m = int(m) + 1
	if m == 60:
		h = incH(h)
		m = 0
	m = str(m)
	if len(m) == 1:
		m = '0' + m
	return (h, m)
(h, m) = input().split(':')
for i in range(3600):
	if isP(h, m):
		print(i)
		import sys
		sys.exit(0)
	(h, m) = incM(h, m)


def pal(var):
	rev = var[::-1]
	if rev == var:
		return 1
	else:
		return 0
string = input()
if pal(string) == 1:
	print('0')
	quit()
a = int(string[0])
b = int(string[1])
c = int(string[3])
d = int(string[4])
time = 0
while True:
	d += 1
	time += 1
	if d == 10:
		d = 0
		c += 1
		if c == 6:
			c = 0
	if d == 0 and c == 0:
		b += 1
		if b == 10:
			b = 0
			a += 1
		if a == 2 and b == 4:
			a = 0
			b = 0
	if pal(str(a) + str(b) + ':' + str(c) + str(d)) == 1:
		break
print(time)


(hh, dd) = list(map(int, input().split(':')))
cnt = 0
while True:
	H = str(hh)
	D = str(dd)
	if len(H) < 2:
		H = '0' + H
	if len(D) < 2:
		D = '0' + D
	if H == D[::-1]:
		print(cnt)
		return
	dd += 1
	if dd > 59:
		dd = 0
		hh += 1
	if hh > 23:
		hh = 0
	cnt += 1


n = input().split(':')
a = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412, 1440]
m = int(n[0]) * 60 + int(n[1])
nearest = 1441
for i in a:
	if i - m < nearest and i - m >= 0:
		nearest = i - m
print(nearest)


(a, b) = input().split(':')
ans = 0
while a[1] != b[0] or a[0] != b[1]:
	ans += 1
	x = 0
	if b == '59':
		x += 1
	b = str((int(b) + 1) % 60).zfill(2)
	a = str((int(a) + x) % 24).zfill(2)
print(ans)


def parse_time(s):
	(hh, mm) = s.split(':', 1)
	return (int(hh), int(mm))

def increase_time(time):
	(hh, mm) = time
	mm = mm + 1
	if mm == 60:
		(hh, mm) = (hh + 1, 0)
	if hh == 24:
		hh = 0
	return (hh, mm)

def time_to_string(time):
	(hh, mm) = time
	return '%02d:%02d' % (hh, mm)

def is_palindrome(time):
	s = time_to_string(time)
	return s == s[::-1]

def solve(inp):
	time = parse_time(inp)
	elapsed = 0
	while not is_palindrome(time):
		elapsed += 1
		time = increase_time(time)
	return elapsed
print(solve(input()))


s = input()
k = 0
ans = 0
while s != s[::-1]:
	k += 1
	t = int(s[3:]) + 1
	if t == 60:
		u = str((int(s[:2]) + 1) % 24)
		s = '0' * (2 - len(u)) + u + ':00'
	else:
		s = s[:3] + '0' * (2 - len(str(t))) + str(t)
print(k)


def check(h, m):
	if h % 10 * 10 + h // 10 == m:
		return True
	else:
		return False
(h, m) = map(int, input().split(':'))
time = 0
while check(h, m) == False:
	m += 1
	if m == 60:
		m = 0
		h += 1
	if h == 24:
		h = 0
	time += 1
print(time)


(h, m) = input().split(':')
res = 0
while True:
	if h == m[::-1]:
		break
	res += 1
	yy = int(m) + 1
	if yy == 60:
		m = '00'
		yy = int(h) + 1
		if yy == 24:
			h = '00'
		else:
			h = str(yy).rjust(2, '0')
	else:
		m = str(yy).rjust(2, '0')
print(res)


time = input().split(':')

def palindrome(time):
	if time[0] == time[3] and time[1] == time[2]:
		return True
	else:
		return False
time = time[0] + time[1]
counter = 0
minutes = int(time[2:])
hours = int(time[:2])
while not palindrome(time):
	minutes += 1
	minutes = minutes % 60
	if minutes == 0:
		hours += 1
	hours = hours % 24
	if hours < 10:
		if minutes < 10:
			time = '0' + str(hours) + '0' + str(minutes)
		else:
			time = '0' + str(hours) + str(minutes)
	elif minutes < 10:
		time = str(hours) + '0' + str(minutes)
	else:
		time = str(hours) + str(minutes)
	counter += 1
print(counter)


def main():
	line = input()
	hh = int(line[0:2])
	mm = int(line[3:5])
	mins = 0
	while True:
		if hh // 10 == mm % 10 and hh % 10 == mm // 10:
			break
		mins += 1
		mm += 1
		if mm == 60:
			mm = 0
			hh += 1
		if hh == 24:
			hh = 0
	print(mins)
main()


s = input()
ans = 0
while s != s[::-1]:
	minutes = int(s[:2]) * 60 + int(s[3:]) + 1
	s = str(minutes // 60 % 24).zfill(2) + ':' + str(minutes % 60).zfill(2)
	ans += 1
print(ans)


def ispal(hh, mm):
	if hh // 10 == mm % 10 and hh % 10 == mm // 10:
		return True
	else:
		return False
time = input()
(hh, mm) = map(int, time.split(sep=':'))
ans = 0
while not ispal(hh, mm):
	mm = (mm + 1) % 60
	if mm == 0:
		hh = (hh + 1) % 24
	ans = ans + 1
print(ans)


n = input()
a = n[0:2]
b = int(n[3:])
c = int(a)
cnt = 0
while int(a[::-1]) != b:
	a = int(a)
	b += 1
	cnt += 1
	if b >= 60:
		b -= 60
		a += 1
	if a >= 24:
		a -= 24
	if a < 10:
		a = '0' + str(a)
	else:
		a = str(a)
print(cnt)


def f(x, y):
	xx = str(x)
	if len(xx) == 1:
		xx = '0' + xx
	yy = str(y)
	if len(yy) == 1:
		yy = '0' + yy
	return yy[::-1] != xx
read = lambda : map(int, input().split(':'))
(a, b) = read()
cnt = 0
while f(a, b):
	b += 1
	if b == 60:
		a += 1
		b = 0
	if a == 24:
		a = 0
	cnt += 1
print(cnt)


(sh, sm) = map(int, input().split(':'))
mins = sh * 60 + sm
can = []
for h in range(24):
	ms = int('{:02d}'.format(h)[::-1])
	if 0 <= ms < 60:
		can.append(h * 60 + ms)
can.append(24 * 60)
print(min((k for k in can if k >= mins)) - mins)


def is_palindrome(string):
	if string == string[::-1]:
		return True
	return False

def delete_trash(string):
	for char in string:
		if char.isnumeric():
			string += char
	return string

def get_hours(_time):
	if _time[0] == '0':
		_x = _time[1]
	else:
		_x = int(str(_time[0] + _time[1]))
	return int(_x)

def get_minutes(_time):
	if _time[3] == '0':
		_y = _time[4]
	else:
		_y = int(str(_time[3] + _time[4]))
	return int(_y)
time = input()
flag = False
tmp = ''
answer = ''
if is_palindrome(time):
	print('0')
elif str(time[0] + time[1]) == '23':
	if int(str(time[3] + time[4])) <= 32:
		print(32 - int(str(time[3] + time[4])))
	else:
		print(60 - int(str(time[3] + time[4])))
else:
	x = get_hours(_time=time)
	y = get_minutes(_time=time)
	for i in range(24):
		for j in range(60):
			tmp = ''
			if len(str(i)) == 1 and len(str(j)) == 1:
				tmp += '0' + str(i) + ':' + '0' + str(j)
			elif len(str(i)) == 1 and len(str(j)) == 2:
				tmp += '0' + str(i) + ':' + str(j)
			elif len(str(i)) == 2 and len(str(j)) == 1:
				tmp += str(i) + ':' + '0' + str(j)
			else:
				tmp += str(i) + ':' + str(j)
			if is_palindrome(tmp) and x * 60 * 60 + y * 60 < get_hours(tmp) * 60 * 60 + get_minutes(tmp) * 60:
				answer = tmp
				flag = True
				break
		if flag:
			break
	if flag:
		a = get_hours(_time=answer)
		b = get_minutes(_time=answer)
		print(int((a * 60 * 60 + b * 60 - x * 60 * 60 - y * 60) / 60))


from sys import stdin, stdout
MN = 200005
inp = stdin.readline()
h = int(inp[0]) * 10 + int(inp[1])
m = int(inp[3]) * 10 + int(inp[4])

def pal(a, b):
	return a // 10 == b % 10 and a % 10 == b // 10
res = 0
while True:
	if pal(h, m):
		stdout.write(str(res))
		exit(0)
	res += 1
	m += 1
	if m == 60:
		m = 0
		h += 1
		if h == 24:
			h = 0


def fu(s):
	(h, m) = s.split(':')
	if m[::-1] == h:
		return ('yes', s)
	else:
		m = str(int(m) + 1)
		if int(m) == 60:
			m = '00'
			h = str(int(h) + 1)
			if int(h) == 24:
				h = '00'
		if len(h) < 2:
			h = '0' + h
		if len(m) < 2:
			m = '0' + m
		s = ':'.join([h, m])
		return ('no', s)
from sys import stdin
s = stdin.readline().strip()
flag = 1
k = 0
while flag:
	r = fu(s)
	if r[0] == 'yes':
		flag = 0
	else:
		k = k + 1
		s = r[1]
print(k)


(h, m) = list(map(int, input().split(':')))

def rev(t):
	s = ''
	for c in reversed(t):
		s += c
	return s

def fun(hour, minute):
	(sm, sh) = ('', '')
	if minute < 10:
		sm = '0' + str(minute)
	else:
		sm = str(minute)
	if hour < 10:
		sh = '0' + str(hour)
	else:
		sh = str(hour)
	return sh + sm

def is_palindrome(t):
	if rev(t) == t:
		return True
	return False
res = 0
while True:
	if is_palindrome(fun(h, m)):
		print(res)
		break
	m += 1
	if m == 60:
		h += 1
		m = 0
	if h == 24:
		h = 0
	res += 1


def compute_time_string_from_mins(mins):
	hrs = mins // 60 % 24
	mins = mins % 60
	str_time = '%02d:%02d' % (hrs, mins)
	return str_time

def extract_total_mins_from_time_string_24h(time_string):
	time_string = time_string.split(':')
	hrs = int(time_string[0]) % 24
	mins = int(time_string[1])
	total_mins = hrs * 60 + mins
	return total_mins

def compute_next_time_palidrome(time_input):
	time_input = time_input.rstrip()
	eingeschlafen = extract_total_mins_from_time_string_24h(time_input)
	total_mins = eingeschlafen
	while True:
		if time_input == time_input[::-1]:
			return total_mins - eingeschlafen
		total_mins += 1
		time_input = compute_time_string_from_mins(total_mins)

def main():
	import sys
	for line in sys.stdin:
		print(compute_next_time_palidrome(line))
main()


(a, b) = input().split(':')
a = int(a)
b = int(b)
anw = 0

def palin(s):
	return s == s[::-1]
while not palin(str(a).zfill(2) + str(b).zfill(2)):
	anw += 1
	b += 1
	if b == 60:
		b = 0
		a += 1
	if a == 24:
		a = 0
print(anw)


(h, m) = [i for i in input().split(':')]
if int(m) <= int(h[::-1]) < 60:
	print(int(h[::-1]) - int(m))
	exit(0)
result = 0
if h == '23':
	h = '00'
elif h == '09':
	h = '10'
elif h == '19':
	h = '20'
elif h[1] in '56789':
	result += 60 * (ord('9') - ord(h[1]))
	h = str(int(h[0]) + 1) + '0'
else:
	h = h[0] + str(int(h[1]) + 1)
print(60 - int(m) + int(h[::-1]) + result)


palindrome = [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412, 1440]
(H, M) = map(int, input().split(':'))
min = H * 60 + M
if min in palindrome:
	print(0)
else:
	for i in range(0, 16):
		if palindrome[i] < min and min < palindrome[i + 1]:
			print(palindrome[i + 1] - min)
			break


(h, m) = input().split(':')
t = 0
while h[0] != m[1] or h[1] != m[0]:
	t += 1
	if int(m) == 59:
		h = ('0' if (int(h) + 1) % 24 < 10 else '') + '%d' % ((int(h) + 1) % 24)
	m = ('0' if (int(m) + 1) % 60 < 10 else '') + '%d' % ((int(m) + 1) % 60)
print(t)


def ispal(h: str, m: str):
	global answer
	if h.__len__() != 2:
		h = '0' + h
	if m.__len__() != 2:
		m = '0' + m
	x = h == m[::-1]
	if x == False:
		return False
	print(answer)
	return True
(h, m) = input().split(':')
answer = 0
for i in range(0, 24):
	for j in range(0, 60):
		if ispal(str((int(h) + i + ((int(m) + j) // 60 >= 1)) % 24), str((int(m) + j) % 60)):
			exit()
		answer += 1


def ispal(s):
	l = list(s)
	l1 = l[::-1]
	if l == l1:
		return True
	return False
s = str(input())
h = s[0:2]
m = s[3:]
h1 = int(h)
m1 = int(m)
l1 = [(0, 0), (1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (10, 1), (11, 11), (12, 21), (13, 31), (14, 41), (15, 51), (20, 2), (21, 12), (22, 22), (23, 32)]
if h1 == 23 and m1 > 32:
	print(60 - m1)
	exit()
if s in l1:
	print(0)
	exit()
for i in range(len(l1)):
	if h1 == l1[i][0] and m1 <= l1[i][1]:
		print(l1[i][1] - m1)
		exit()
	elif h1 < l1[i][0]:
		print(l1[i][1] - m1 + 60 * (l1[i][0] - h1))
		exit()


from sys import stdin

def main():
	while True:
		try:
			(_hh, _mm) = map(int, stdin.readline().split(':'))
		except ValueError:
			break
		_tt = _hh * 60 + _mm
		i = 0
		while True:
			if _tt % 60 % 10 == _tt // 60 // 10 and _tt % 60 // 10 == _tt // 60 % 10:
				print(i)
				break
			_tt = (_tt + 1) % (24 * 60)
			i += 1
main()


import sys
import os
import math
import re
s = input()

def palindrome(h, m):
	return h // 10 == m % 10 and h % 10 == m // 10
h = int(s[:2])
m = int(s[3:])
count = 0
while palindrome(h, m) is False:
	m += 1
	if m > 59:
		m = 0
		h += 1
	if h > 23:
		h = 0
	count += 1
print(count)


time = input().split(':')

def polindrome(n):
	if time[0] == time[1][1] + time[1][0]:
		return True
	else:
		return False
minutes = int(time[1])
hours = int(time[0])
time_start = 0
while True:
	if polindrome(time) == False:
		minutes = minutes + 1
		time_start = time_start + 1
		time[1] = str(minutes)
		if minutes <= 9:
			time[1] = '0' + str(minutes)
		if minutes == 60:
			minutes = 0
			time[1] = '00'
			hours = hours + 1
			time[0] = str(hours)
		if minutes <= 9:
			time[1] = '0' + str(minutes)
		if hours <= 9:
			time[0] = '0' + str(hours)
		if hours == 24:
			time[0] = '00'
			time[1] = '00'
			hours = 0
	else:
		print(time_start)
		break


def main():
	(h, m) = list(map(int, input().split(':')))
	a = 0
	while h // 10 != m % 10 or h % 10 != m // 10:
		a += 1
		m += 1
		if m >= 60:
			h += 1
		h %= 24
		m %= 60
	print(a)
main()


now = list(map(int, input().split(':')))
now = now[0] * 60 + now[1]
i = now
while True:
	h = str(i // 60).rjust(2, '0')
	m = str(i % 60).rjust(2, '0')
	if h[::-1] == m:
		print((i - now) % (24 * 60))
		break
	else:
		i += 1
		i %= 24 * 60


def solve():
	(hh, mm) = list(map(int, get(str).split(':')))
	m = 0

	def ispalindrome(hh, mm):
		s = str(hh).zfill(2) + str(mm).zfill(2)
		return s == s[::-1]
	for m in range(60 * 24 + 1):
		if mm == 60:
			mm = 0
			hh += 1
			if hh == 24:
				hh = 0
		if ispalindrome(hh, mm):
			break
		mm += 1
	return m
_testcases = '\n05:39\n\n11\n\n13:31\n\n0\n\n23:59\n\n1\n\n'.strip()
import re
import sys
import math
import heapq
from heapq import heapify, heappop, heappush
import bisect
import string
from bisect import bisect_left, bisect_right
import operator
from operator import itemgetter, attrgetter
import itertools
import collections
inf = float('inf')
sys.setrecursionlimit(10000)

def tree():
	return collections.defaultdict(tree)

def cache(func):
	cache_dict = {}

	def _cached_func(*args, _get_cache=False):
		if _get_cache:
			return cache_dict
		if args in cache_dict:
			return cache_dict[args]
		cache_dict[args] = func(*args)
		return cache_dict[args]
	return _cached_func

def equal(x, y, epsilon=1e-06):
	if -epsilon <= x - y <= epsilon:
		return True
	if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:
		return False
	return -epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon

def get(_type):
	if type(_type) == list:
		if len(_type) == 1:
			_type = _type[0]
			return list(map(_type, input().strip().split()))
		else:
			return [_type[i](inp) for (i, inp) in enumerate(input().strip().split())]
	else:
		return _type(input().strip())
(_p, print) = (print, lambda *a, **b: None)
_p(solve())


(ab, cd) = input().split(':')
ba = int(ab[1] + ab[0])
(ab, cd) = map(int, [ab, cd])
res = 0
while cd != ba:
	cd += 1
	res += 1
	if cd == 60:
		ab += 1
		cd = 0
		ba = ab % 10 * 10 + ab // 10
	if ab == 24:
		ab = 0
		ba = 0
print(res)


s = input().split(':')
a = s[0]
b = s[1]
cnt = 0
s = a + b
k = 12
while s != s[::-1]:
	cnt += 1
	if int(b) == 59:
		if int(a) == 23:
			break
		elif len(str(int(a))) == 1 and int(a) != 9:
			a = '0' + str(int(a) + 1)
			b = '00'
		else:
			a = str(int(a) + 1)
			b = '00'
	elif int(b) < 9:
		b = '0' + str(int(b) + 1)
	else:
		b = str(int(b) + 1)
	s = a + b
print(cnt)


import datetime
c = input()
start_clock = datetime.datetime.strptime(c, '%H:%M')
end_clock = datetime.datetime.strptime(c, '%H:%M')
while end_clock.strftime('%H') != end_clock.strftime('%M')[::-1]:
	end_clock += datetime.timedelta(minutes=1)
print(int((end_clock - start_clock).total_seconds() // 60))


t = input().replace(':', '')
hh = t[:2]
mm = t[2:]
c = 0
while True:
	x = '0' * (2 - len(hh)) + hh
	y = '0' * (2 - len(mm)) + mm
	if x + y == (x + y)[::-1]:
		print(c)
		break
	mm = str(int(mm) + 1)
	if int(mm) == 60:
		hh = str(int(hh) + 1)
		mm = '0'
	if int(hh) == 24:
		hh = '0'
	c += 1


import math
(a, b) = map(int, input().split(':'))
ans = 0
while a != b % 10 * 10 + b // 10:
	ans += 1
	b += 1
	if b == 60:
		a = a + 1
		b = 0
		if a == 24:
			a = 0
print(ans)


(hh, mm) = input().split(':')
ans = 0
while hh != mm[::-1]:
	ans += 1
	mm = int(mm) + 1
	hh = int(hh)
	hh += mm // 60
	mm %= 60
	hh %= 24
	mm = '0' * (mm < 10) + str(mm)
	hh = '0' * (hh < 10) + str(hh)
print(ans)


import sys
input = sys.stdin.readline
time = [int(x) for x in input().split(':')]
count = 0
while True:
	first = str(time[0])
	second = str(time[1])
	if len(first) == 1:
		first = '0' + first
	if len(second) == 1:
		second = '0' + second
	if first == second[::-1]:
		break
	count += 1
	if time[1] < 59:
		time[1] += 1
	else:
		time[1] = 0
		if time[0] < 23:
			time[0] += 1
		else:
			time[0] = 0
print(count)


t = [int(i) for i in input().split(':')]
m = 60
h = 24
cnt = 0

def isPal(s):
	t1 = 0
	t2 = 0
	if s[0] < 10:
		t1 = '0{}'.format(s[0])
	else:
		t1 = '{}'.format(s[0])
	if s[1] < 10:
		t2 = '0{}'.format(s[1])
	else:
		t2 = '{}'.format(s[1])
	t = t1 + ':' + t2
	return t != t[::-1]
while isPal(t):
	cnt += 1
	t[1] += 1
	if t[1] > 59:
		t[0] += 1
		t[0] = t[0] % h
	t[1] = t[1] % m
print(cnt)


x = input()
y = x[:2] + x[-2:]
z = reversed(y)
count = 0
while list(z) != list(y):
	count += 1
	x = str(int(y) + 1)
	if len(list(x)) == 1:
		x = '000' + x
	elif len(list(x)) == 2:
		x = '00' + x
	elif len(list(x)) == 3:
		x = '0' + x
	if int(x[-2:]) == 60:
		x = str(int(x[:2]) + 1) + '00'
		if int(x[:2]) == 24:
			x = '0000'
	y = x
	if len(list(x)) == 1:
		y = '000' + x
	elif len(list(x)) == 2:
		y = '00' + x
	elif len(list(x)) == 3:
		y = '0' + x
	z = reversed(y)
print(count)


def vert(ch, m):
	if ch // 10 == m % 10 and ch % 10 == m // 10:
		return 1
	else:
		return 0
tmp = str(input())
ch = int(tmp[0]) * 10 + int(tmp[1])
m = int(tmp[3]) * 10 + int(tmp[4])
vr = 0
while not vert(ch, m):
	m += 1
	vr += 1
	if m == 60:
		m = 0
		ch += 1
	if ch == 24:
		ch = 0
print(vr)


def list_input():
	return list(map(int, input().split()))
s = list(map(int, input().split(':')))
y = s[0] * 60 + s[1]
for x in range(0, 1440):
	z = x + y
	if z >= 1440:
		z -= 1440
	hh = z // 60
	mm = z % 60
	hs = str(hh)
	ms = str(mm)
	if len(hs) == 1:
		hs = '0' + hs
	if len(ms) == 1:
		ms = '0' + ms
	if hs[0] == ms[1] and hs[1] == ms[0]:
		print(x)
		exit(0)


s = input()
count = 0
h = int(s[0:2])
m = int(s[3:])
ans = True
while ans == True:
	if m >= 60:
		m %= 60
		h += 1
		if h > 23:
			h %= 24
	if h > 23:
		h %= 24
	if h < 10:
		u = '0' + str(h)
	if h >= 10:
		u = str(h)
	if m < 10:
		y = '0' + str(m)
	if m >= 10:
		y = str(m)
	o = str(u) + str(y)
	if o == o[::-1]:
		ans = False
		break
	count += 1
	m += 1
print(count)


time = input()

def is_palindrome(string):
	if string == string[::-1]:
		return True
	else:
		return False

def add_minute(time_str, number):
	hour = int(time_str[:2])
	minute = int(time_str[3:])
	if minute + number < 60:
		minute += number
	else:
		minute = minute + number - 60
		if hour < 23:
			hour += 1
		else:
			hour = 0
	return '{0}{1}:{2}{3}'.format('0' if hour < 10 else '', hour, '0' if minute < 10 else '', minute)

def difference(time1, time2):
	min1 = to_minute(time1)
	min2 = to_minute(time2)
	return min2 - min1

def to_minute(time_str):
	hour = int(time_str[:2])
	minute = int(time_str[3:])
	if hour == minute == 0:
		return 24 * 60
	else:
		return hour * 60 + minute
new_time = time
while not is_palindrome(new_time):
	new_time = add_minute(new_time, 1)
print(difference(time, new_time))


time = input().split(':')
hour = time[0]
minute = time[1]

def is_palin(hour, minute):
	return hour == minute[::-1]
total = 0
while not is_palin(hour, minute):
	total += 1
	minute = str(int(minute) + 1)
	if len(minute) != 2:
		minute = '0' + minute
	if int(minute) >= 60:
		minute = '00'
		hour = str(int(hour) + 1)
		if len(hour) != 2:
			hour = '0' + hour
		if int(hour) >= 24:
			hour = '00'
print(total)


import sys

def minutos(hora):
	a = int(hora[:2])
	b = int(hora[3:])
	return 60 * a + b
palin = []
for i in range(0, 24):
	hora = ''
	if i < 10:
		hora += '0'
	hora += str(i)
	if hora[::-1] < '60':
		palin.append(hora + ':' + hora[::-1])
hora = sys.stdin.readline()
hora = hora[:-1]
greater = None
for (index, x) in enumerate(palin):
	if hora <= x:
		greater = index
		break
if greater != None:
	print(minutos(palin[greater]) - minutos(hora))
else:
	print(minutos('24:00') - minutos(hora))


time = input()
palyndroms = ['00:00', '01:10', '02:20', '03:30', '04:40', '05:50', '10:01', '11:11', '12:21', '13:31', '14:41', '15:51', '20:02', '21:12', '22:22', '23:32']
if time == time[::-1]:
	print(0)
elif time > '23:32':
	print(60 - int(time[3:]))
else:
	for palyndrom in palyndroms:
		if time < palyndrom:
			print((int(palyndrom[:2]) - int(time[:2])) * 60 + int(palyndrom[3:]) - int(time[3:]))
			break


s = input()
if s == s[:-1]:
	print(0)
	exit()
h = int(s[:2])
m = int(s[3:])
H = ''
M = ''
k = 0
while s != s[::-1]:
	m += 1
	if m == 60:
		m = 0
		h += 1
	if h == 24:
		h = 0
	if h < 10:
		H = '0' + str(h)
	else:
		H = str(h)
	if m < 10:
		M = '0' + str(m)
	else:
		M = str(m)
	s = H + M
	k += 1
print(k)


ts = list(input().split(':'))
ans = 0
l1 = ['00', '01', '02', '03', '04', '05', '10', '11', '12', '13', '14', '15', '20', '21', '22', '23']
l2 = ['00', '10', '20', '30', '40', '50', '01', '11', '21', '31', '41', '51', '02', '12', '22', '32']
if ts[0] in l1:
	h = l1.index(ts[0])
	if l2[h] >= ts[1]:
		ans = abs((int(l1[h]) - int(ts[0])) * 60 + int(l2[h]) - int(ts[1]))
		print(ans)
	elif h == len(l1) - 1 and l2[h] < ts[1]:
		ans = abs(60 - int(ts[1]))
		print(ans)
	elif int(l2[h + 1]) - int(ts[1]) < 0:
		ans = (abs(int(l1[h + 1]) - int(ts[0])) - 1) * 60 + (60 + int(l2[h + 1])) - int(ts[1])
		print(ans)
	else:
		ans = abs(int(l1[h + 1]) - int(ts[0])) * 60 + int(l2[h + 1]) - int(ts[1])
		print(ans)
elif int(ts[0]) in range(6, 10):
	h = l1.index('10')
	if int(ts[1]) >= int(l2[h]):
		ans = (10 - int(ts[0])) * 60 - abs(int(ts[1]) - int(l2[h]))
	else:
		ans = (10 - int(ts[0])) * 60 + abs(int(ts[1]) + int(l2[h]))
	print(ans)
else:
	h = l1.index('20')
	if int(ts[1]) >= int(l2[h]):
		ans = (20 - int(ts[0])) * 60 - abs(int(ts[1]) - int(l2[h]))
	else:
		ans = (20 - int(ts[0])) * 60 + abs(int(ts[1]) - int(l2[h]))
	print(ans)


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import re
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import log2, sqrt
from collections import defaultdict
s = S()
(h, m) = (int(s[:2]), int(s[3:]))
mi = 0
b = int(m)
while h % 10 != m // 10 or m % 10 != h // 10:
	m += 1
	mi += 1
	if m == 60:
		h += 1
	m %= 60
	h %= 24
print(mi)


(h, m) = (int(i) for i in input().split(':'))
cnt = 0
while 1:
	hs = str(h)
	ms = str(m)
	if len(hs) == 1:
		hs = '0' + hs
	if len(ms) == 1:
		ms = '0' + ms
	if hs[::-1] == ms:
		break
	cnt += 1
	m += 1
	if m == 60:
		m = 0
		h += 1
		if h == 24:
			h = 0
print(cnt)


(h, m) = [int(i) for i in input().split(':')]
c = 0
while True:
	s = str(h).rjust(2, '0') + str(m).rjust(2, '0')
	if s == s[::-1]:
		break
	c += 1
	m += 1
	if m >= 60:
		m %= 60
		h += 1
	if h == 24:
		h = 0
print(c)


def pal(t):
	return t[0][0] == t[1][1] and t[0][1] == t[1][0]

def inc(t):
	t[1][1] += 1
	if t[1][1] == 10:
		t[1][1] = 0
		t[1][0] += 1
		if t[1][0] == 6:
			t[1][0] = 0
			t[0][1] += 1
			if t[0][0] == 2 and t[0][1] == 4:
				t[0][0] = 0
				t[0][1] = 0
			elif t[0][1] == 10:
				t[0][1] = 0
				t[0][0] += 1
inp = input().rstrip().split(':')
t = [[int(inp[0][0]), int(inp[0][1])], [int(inp[1][0]), int(inp[1][1])]]
ans = 0
while not pal(t):
	inc(t)
	ans += 1
print(ans)


(st, dk) = input().split(':')
st = int(st)
dk = int(dk)
if st < 10:
	l1 = [0, st]
else:
	l1 = [int(str(st)[0]), int(str(st)[1])]
if dk < 10:
	l2 = [0, dk]
else:
	l2 = [int(str(dk)[0]), int(str(dk)[1])]
z = 0

def is_palindrome(a, b):
	if list(reversed(l1)) == l2:
		return True
	return False
while is_palindrome(l1, l2) == False:
	z += 1
	l2[1] += 1
	if l2[1] > 9:
		l2[1] = 0
		l2[0] += 1
		if l2[0] == 6:
			l2[0] = 0
			l1[1] += 1
			if l1[1] > 9:
				l1[1] = 0
				l1[0] += 1
			if l1[0] == 2 and l1[1] == 4:
				l1[0] = 0
				l1[1] = 0
print(z)


def isPalindrome(hh, mm):
	s = '%0.2d%0.2d' % (hh, mm)
	return s == s[::-1]
(hh, mm) = map(int, input().split(':'))
ans = 0
while True:
	if isPalindrome(hh, mm):
		print(ans)
		break
	ans += 1
	mm += 1
	hh += mm // 60
	mm %= 60
	hh %= 24


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import re
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import log2, sqrt
from collections import defaultdict
s = S().split(':')
t = ''.join(s)
if t == t[::-1]:
	print(0)
else:
	arr = []
	for i in range(10):
		for j in range(10):
			for k in range(10):
				for l in range(10):
					x = str(i) + str(j) + str(k) + str(l)
					if x == x[::-1] and int(str(k) + str(l)) <= 59 and (int(str(i) + str(j)) <= 23):
						arr.append(x)
	mi = maxsize
	if s[0] == '23' and int(s[1]) >= 32:
		print(60 - int(s[1]))
	else:
		for i in arr:
			d = (int(i[:2]) - int(t[:2])) * 60 + (int(i[2:]) - int(t[2:]))
			if d < mi and d >= 0:
				mi = d
		print(mi)


(h, m) = map(int, input().split(':'))

def isPal(s1, s2):
	if s1[0] == s2[1] and s1[1] == s2[0]:
		return True
	return False
k = 0
i = h
j = m
f = False
while i < 24 and (not f):
	hh = '0' + str(i) if i // 10 == 0 else str(i)
	while j < 60 and (not f):
		mm = '0' + str(j) if j // 10 == 0 else str(j)
		if isPal(hh, mm):
			f = True
			break
		k += 1
		j += 1
	i += 1
	j = 0
print(k)


def stri(x):
	if x >= 10:
		return str(x)
	return '0' + str(x)
(h, m) = [int(item) for item in input().split(':')]
c = 0
while (stri(h) + stri(m))[::-1] != stri(h) + stri(m):
	if m == 59:
		m = 0
		if h == 23:
			h = 0
		else:
			h += 1
	else:
		m += 1
	c += 1
print(c)


def one_min(h, m):
	(h, m) = (int(h), int(m))
	m += 1
	if m == 60:
		h = (h + 1) % 24
		m = 0
	return (str(h).zfill(2), str(m).zfill(2))
(h, m) = input().split(':')
if str(h).zfill(2) == str(m)[::-1]:
	print(0)
else:
	c = 0
	while h != m[::-1]:
		(h, m) = one_min(h, m)
		c += 1
	print(c)


tiempo = input()
h1 = int(tiempo[0])
h2 = int(tiempo[1])
m1 = int(tiempo[3])
m2 = int(tiempo[4])
ans = 0
if h1 == m2 and h2 == m1:
	print(ans)
else:
	while True:
		m2 += 1
		if m2 == 10:
			m2 = 0
			m1 += 1
		if m1 == 6:
			m1 = 0
			h2 += 1
		if h2 == 10:
			h1 += 1
			h2 = 0
		if h1 == 2:
			if h2 == 4:
				h1 = 0
				h2 = 0
		ans += 1
		if h1 == m2 and h2 == m1:
			break
	print(ans)


s = input()
lst = s.split(':')
hh = lst[0]
mm = lst[1]
if True:
	if int(hh[1]) <= 5:
		num1 = hh[1] + hh[0]
		if int(num1) >= int(mm):
			print(int(num1) - int(mm))
		elif hh[1] == '5':
			sm = 60 - int(mm) + int(hh[0]) + 1
			sm += 4 * 60
			print(sm)
		else:
			if hh == '23':
				print(60 - int(mm))
				exit()
			num1 = str(int(hh[1]) + 1) + hh[0]
			sm = 60 - int(mm) + int(num1)
			print(sm)
	else:
		sm = 60 - int(mm) + int(hh[0]) + 1
		sm += (10 - int(hh[1]) - 1) * 60
		print(sm)


time = input()
(h, m) = time.split(':')
(h, m) = (int(h), int(m))
currentTime = h * 60 + m

def solve():
	for i in range(24):
		if int(str(i).zfill(2)[::-1]) < 60:
			current = i * 60 + int(str(i).zfill(2)[::-1])
			if current >= currentTime:
				return current - currentTime
	return 60 - m
print(solve())


u = input().split(':')
h = u[0]
m = u[1]

def add(minute):
	hh = minute // 60 + int(h)
	mm = minute % 60 + int(m)
	if mm >= 60:
		mm -= 60
		hh += 1
	if hh >= 24:
		hh -= 24
	if hh < 10:
		hh = '0' + str(hh)
	else:
		hh = str(hh)
	if mm < 10:
		mm = '0' + str(mm)
	else:
		mm = str(mm)
	strr = hh + mm
	return strr == strr[::-1]
for i in range(0, 1000000):
	if add(i):
		print(i)
		break


s = input()
h = int(s[:2])
m = int(s[3:])
x = 0
while h % 10 != m // 10 or h // 10 != m % 10:
	m += 1
	h += m // 60
	m = m % 60
	h = h % 24
	x += 1
print(x)


def is_p(h, m):
	h = str(h)
	m = str(m)
	if len(h) == 1:
		h = '0' + h
	if len(m) == 1:
		m = '0' + m
	if h == m[1] + m[0]:
		return True
	return False
minutos = 0
(h, m) = list(map(int, input().split(':')))
pali = is_p(h, m)
while not pali:
	minutos += 1
	m += 1
	if m >= 60:
		h = (h + 1) % 24
		m = 0
	pali = is_p(h, m)
print(minutos)


k = str(input())
sinpunto = k.split(':')
hora = sinpunto[0]
min = sinpunto[1]
n = hora + min
x = 1
cont = 0
while x == 1:
	n = str(n)
	r = n[::-1]
	if r == n:
		x = 0
		break
	else:
		min = str(int(min) + 1)
		if len(min) == 1:
			min = '0' + min
		if min == '60':
			hora = str(int(hora) + 1)
			min = '00'
		if len(hora) == 1:
			hora = '0' + hora
		if hora == '24':
			hora = '00'
		n = hora + min
		cont = cont + 1
print(cont)


__author__ = 'artyom'

def main():
	s = read(0).split(':')
	c = 0
	while s[0] != s[1][::-1]:
		n = int(s[1]) + 1
		if n == 60:
			s[1] = '00'
			n = int(s[0])
			if n == 23:
				s[0] = '00'
			else:
				s[0] = str(n + 1).zfill(2)
		else:
			s[1] = str(n).zfill(2)
		c += 1
	return c

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s)
write(main())


(hh, mm) = map(int, input().split(':'))
ans = 0
isPalindrome = lambda x: x[:] == x[::-1]
while True:
	if isPalindrome('%0.2d%0.2d' % (hh, mm)):
		print(ans)
		break
	mm += 1
	hh += mm // 60
	(mm, hh, ans) = (mm % 60, hh % 24, ans + 1)


time = input()
hour = time[0:2]
minute = time[3:5]

def check_palinedrome(hour, minute):
	if hour[::-1] == minute:
		return True
	return False
count = 0
while not check_palinedrome(hour, minute):
	int_minute = int(minute)
	int_hour = int(hour)
	int_minute += 1
	if int_minute == 60:
		int_minute = 0
		int_hour += 1
		if int_hour == 24:
			int_hour = 0
	minute = str(int_minute).zfill(2)
	hour = str(int_hour).zfill(2)
	count += 1
print(count)


def is_palindrom(x):
	xrev = ''
	for i in range(len(x) - 1, -1, -1):
		xrev += x[i]
	return x == xrev
s = input().split(':')
time = list(map(int, s))
string_time = s
count = 0
for i in range(5000):
	if is_palindrom(string_time[1] + string_time[0]):
		print(count)
		break
	time[1] += 1
	count += 1
	if time[1] % 60 == 0:
		time[0] += 1
		time[1] = 0
		string_time[1] = '00'
		if time[0] % 24 == 0:
			time[0] = 0
			string_time[0] = '00'
	string_time = [str(time[0]), str(time[1])]
	if len(string_time[0]) == 1:
		string_time[0] = '0' + string_time[0]
	if len(string_time[1]) == 1:
		string_time[1] = '0' + string_time[1]


a = input()
if a[::-1] == a:
	print(0)
else:
	k = 0
	a = a.split(':')
	while True:
		a[1] = int(a[1]) + 1
		a[1] = str(a[1])
		k += 1
		if a[1] == '60':
			a[1] = '00'
			a[0] = int(a[0]) + 1
			a[0] = str(a[0])
			if len(a[0]) == 1:
				a[0] = '0' + a[0]
			if a[0] == '24':
				a[0] = '00'
		if len(a[1]) == 1:
			a[1] = '0' + str(a[1])
		if a[1][::-1] == a[0]:
			print(k)
			break


def inverte(mi):
	dezena = int(mi % 10 * 10)
	unid = int(mi / 10)
	return dezena + unid
linha = input().split(':')
hora = int(linha[0])
min = int(linha[1])
cont = 0
while hora != inverte(min):
	min = min + 1
	cont = cont + 1
	if min == 60:
		hora = hora + 1
		min = 0
		if hora == 24:
			hora = 0
print(cont)


def pal(s):
	return str(s) == str(s)[::-1]

def minutes_to_str(minutes_):
	out = ''
	minutes_ = minutes_ % 1440
	hours = minutes_ // 60
	minutes = minutes_ - hours * 60
	if hours <= 9:
		out += '0' + str(hours)
	else:
		out += str(hours)
	if minutes <= 9:
		out += '0' + str(minutes)
	else:
		out += str(minutes)
	return out
(hours, minutes) = input().split(sep=':')
base_minutes = int(hours) * 60 + int(minutes)
answer_minutes = base_minutes
while pal(minutes_to_str(answer_minutes)) == False:
	answer_minutes += 1
print(answer_minutes - base_minutes)


s = input().split(':')
fir = int(s[0])
sec = int(s[1])

def ispal(a, b):
	if len(a) == 1:
		a = '0' + a
	if len(b) == 1:
		b = '0' + b
	if a[::-1] == b:
		return True
ans = 0
while not ispal(str(fir), str(sec)):
	ans += 1
	sec += 1
	if sec == 60:
		sec = 0
		fir += 1
	if fir == 24:
		fir = 0
		sec = 0
print(ans)


def get_digits(num):
	n1 = 0
	if num >= 10:
		n1 = num // 10
	n2 = num % 10
	return (n1, n2)
(hh, mm) = map(int, input().split(':'))
count = 0
(h1, h2) = get_digits(hh)
(m1, m2) = get_digits(mm)
while h1 != m2 or h2 != m1:
	mm += 1
	if mm == 60:
		mm = 0
		hh += 1
		if hh == 24:
			hh = 0
	count += 1
	(h1, h2) = get_digits(hh)
	(m1, m2) = get_digits(mm)
print(count)


def main():
	(h, m) = map(int, input().split(':'))
	for i in range(1440):
		if '%02d' % h == ('%02d' % m)[::-1]:
			break
		(h, m) = divmod(h * 60 + m + 1, 60)
		h %= 24
	print(i)
main()


def is_palindrome(time):
	new = time[::-1]
	if time == new:
		return True
	else:
		return False

def clock(h1, h2, m1, m2):
	m1 += m2 // 10
	m2 = m2 % 10
	h2 += m1 // 6
	m1 = m1 % 6
	h1 += h2 // 10
	h2 = h2 % 10
	if h1 == 2 and h2 == 4:
		h1 = 0
		h2 = 0
	return [h1, h2, m1, m2]
import re
temp = input()
pattern = '\\d'
time = re.findall(pattern, temp)
del temp
ho = int(time[0])
ht = int(time[1])
mo = int(time[2])
mt = int(time[3])
count = []
for i in range(5000):
	if is_palindrome(time):
		print(len(count))
		break
	else:
		mt += 1
		time = clock(ho, ht, mo, mt)
		count.append(i)


def isPalindrome(s):
	t = s[::-1]
	if s == t:
		return True
	else:
		return False
s = input()
h = int(s[0:2])
m = int(s[3:])
count = 0
while isPalindrome('%02d%02d' % (h, m)) == False:
	count += 1
	m += 1
	if m >= 60:
		h += 1
		m -= 60
	if h >= 24:
		h -= 24
print(count)


import sys

def palind(x):
	x = str(x)
	if x == '0':
		return 1
	if x.__len__() == 1:
		x = '000' + x
	elif x.__len__() == 2:
		x = '00' + x
	elif x.__len__() == 3:
		x = '0' + x
	lg = 4
	for i in range(lg):
		if x[i] != x[lg - i - 1]:
			return 0
	return 1
inp = input()
inp = inp.replace(':', '')
cop1 = cop2 = int(inp)
st = dr = 0
while 1:
	if cop1 == 2360:
		cop1 = 0
	elif cop1 % 100 == 60:
		cop1 //= 100
		cop1 *= 100
		cop1 = cop1 + 100
	if palind(cop1):
		break
	cop1 = cop1 + 1
	dr = dr + 1
print(dr)


s = input()
s = s.split(':')
ans = 0
while True:
	if int(s[0][1] + s[0][0]) >= int(s[1]) and int(s[0][1] + s[0][0]) < 60:
		print(ans + int(s[0][1] + s[0][0]) - int(s[1]))
		break
	else:
		s[0] = str((int(s[0]) + 1) % 24)
		if int(s[0]) < 10:
			s[0] = '0' + s[0]
		ans += 60 - int(s[1])
		s[1] = '00'


n = input()
h = int(n[:2])
hs = n[:2]
m = int(n[3:])
ms = n[3:]
count = 0
while True:
	if m == 60:
		m = 0
		ms = '00'
		h += 1
	if h == 24:
		h = 0
	if int(hs) != h and h < 10:
		hs = '0' + str(h)
	elif int(hs) != h:
		hs = str(h)
	if hs[0] == ms[1] and hs[1] == ms[0]:
		print(count)
		exit(0)
	m += 1
	count += 1
	if m < 10:
		ms = '0' + str(m)
	else:
		ms = str(m)


a = input()
b = a[0:2]
c = a[3:5]
x = 0
while b[0] != c[1] or b[1] != c[0]:
	c = str(int(c) + 1)
	if int(c) < 10:
		c = '0' + c
	if int(c) == 60:
		c = '00'
		b = str(int(b) + 1)
		if int(b) < 10:
			b = '0' + b
	if int(b) == 24:
		b = '00'
	x = x + 1
print(x)


s = input()
(heure, minute) = (int(s[0] + s[1]), int(s[3] + s[4]))

def good(x, y):
	a = list(str(x))
	b = list(str(y))
	while len(a) != 2:
		a.insert(0, '0')
	while len(b) != 2:
		b.insert(0, '0')
	return a[::-1] == b
res = 0
while not good(heure, minute):
	res += 1
	minute += 1
	heure += minute // 60
	minute %= 60
	heure %= 24
print(res)


t = input()
l = ['01:10', '02:20', '03:30', '04:40', '05:50', '10:01', '11:11', '12:21', '13:31', '14:41', '15:51', '20:02', '21:12', '22:22', '23:32', '00:00']
if t in l:
	print(0)
	exit()
for i in l:
	if i[:2] > t[:2]:
		print(int(i[3:]) + 60 - int(t[3:]) + 60 * (int(i[:2]) - int(t[:2]) - 1))
		exit()
	if i[:2] == t[:2]:
		if t[3:] > i[3:]:
			continue
		else:
			print(int(i[3:]) - int(t[3:]))
			exit()
print(60 - int(t[3:]))


(h, m) = map(int, input().split(':'))
for i in range(1440):
	b = m + i
	a = (h + b // 60) % 24
	b %= 60
	a = '%02d%02d' % (a, b)
	if a[::-1] == a:
		print(i)
		break