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: interview

Starter code:

Solutions:
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 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)

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

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)


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


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)

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 to_string(n):
    s = str(n)
    if n < 10:
        s = "0" + s
    return s

s1, s2 = list(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)


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)
    



# coding: utf-8

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


h, m = list(map(int, input().split(':')))
c = 0
while True:
    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
    


def b(h, m):
    s = '%02d:%02d'%(h, m)
    return s == s[::-1]

h, m = list(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)


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

def __starting_point():
    solve()
__starting_point()

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


def __starting_point():
    print(solve(input()))

__starting_point()

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

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)    

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


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)

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)


#786
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


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)

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)
		return
	t = (t + 1) % 1440


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)

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