1764.Karen and Morning

Time Limit: 1s Memory Limit: 256MB

Karen is getting ready for a new school day!

1764_1.png

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 Format(From the terminal/stdin)

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

Output Format(To the terminal/stdout)

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.

Sample Input 1

Copy
05:39
     \n

Sample Output 1

Copy
11
  \n

Sample Input 2

Copy
13:31
     \n

Sample Output 2

Copy
0
 \n

Sample Input 3

Copy
23:59
     \n

Sample Output 3

Copy
1
 \n

Hints

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.

Submit

请先 登录

© 2025 FAQs