Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/palindrom-vaqt

Palindrome time

Medium 1000 ms 256 MB 45%
Share

A digital clock shows the time in the $24$-hour format HH:MM. A time is a palindrome if its four digits without the colon (HHMM) read the same left to right and right to left (for example, 05:50, 12:21, 00:00; 12:12 is not a palindrome). The current time is given. Find how many minutes you have to wait until the nearest palindrome time; 00:00 follows 23:59. If the current time is a palindrome itself, the answer is $0$.

Checking the symmetry of a digital clock reading

Input

One line with the current time in the format HH:MM (two-digit hours and minutes).

Output

One integer — the number of minutes to wait.

Note

$00 \le HH \le 23$
$00 \le MM \le 59$

Examples

Input #1
12:21
Output #1
0
Input #2
23:59
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.