407036: GYM102697 007 Clock Seconds

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

007. Clock Secondstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You have a clock that tells time in the usual way: hours, minutes, and seconds. When you wake up in the morning, you want to figure out how many seconds you slept for. Conveniently, you fell asleep the night before at exactly 12:00 AM. Remember that there are 60 seconds in a minute and 60 minutes in an hour.

Input

The first line of input contains a positive integer h indicating the current number of hours displayed on the clock (1 <= h <= 11). The second line of input contains a positive integer m indicating the current number of minutes displayed on the clock (0 <= m <= 59) The third line of input contains a positive integer s indicating the current number of seconds displayed on the clock (0 <= s <= 59) The fourth line of input contains a string a indicating whether it is currently the morning or the afternoon. a will be either AM or PM. You are guaranteed to have slept for less than 24 hours. Also, note that h will never equal 12.

Output

Print a single positive integer t: the number of seconds of sleep that you got.

ExampleInput
6
50
34
AM
Output
24634

加入题单

算法标签: