#T767. 系统升级

系统升级

Description

As is well known, the OJ system undergoes periodic updates each year. However, the OJ team consists of a total of n members, and the administrator hopes that all of them can simultaneously receive the system upgrade notification sent via the OJ platform, with an automatic message sent once the upgrade is completed. However, platform messages are sent in batches once every hour, precisely on the hour. To ensure the members' rest time, messages can only be sent between 8:30 AM and 9:00 PM. If the system upgrade is completed at or after 9:00 PM, the message will be sent in the next batch at 8:00 AM the following day.

Now, the administrator wants to know how long it will take after the system upgrade is completed for the OJ team members to receive the platform notification.

Input Format

The input consists of a single line: Two numbers, h and m, representing the hour and minute when the system upgrade is completed.

Output Format

Output a single number representing the duration in minutes (converting hours to minutes) from the completion of the system upgrade until the team members receive the platform notification.

If the input format is invalid, output the uppercase letter X.

18 7
53
21 0
690
15 0
0

Source

CodesOnline Original Problem