A - Hourly Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

問題文

あるバス停からは毎時 X 分にバスが出ます。 例えば、X=10 の場合、010 分、110 分、\dots2310 分にバスが出ます。 他の時刻にはバスは出ません。

いま、HM 分 (M\neq X) です。次のバスは何分後に出ますか?

制約

  • 0\leq H \leq 23
  • 0\leq X,M \leq 59
  • X\neq M
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

X H M

出力

答えを整数として出力せよ。


入力例 1

30 14 10

出力例 1

20

現在の時刻は 1410 分であり、次にバスが出るのは 1430 分なので、今から 20 分後です。


入力例 2

12 23 30

出力例 2

42

現在の時刻は 2330 分であり、次にバスが出るのは翌日の 012 分なので、今から 42 分後です。


入力例 3

1 17 34

出力例 3

27

Problem Statement

There is a bus stop where buses depart at X minutes past each hour. For example, if X=10, buses depart at 0:10, 1:10, \ldots, and 23:10. No buses depart at any other time.

It is currently M minutes past H (M\neq X). How many minutes are left before the next bus departs?

Constraints

  • 0\leq H \leq 23
  • 0\leq X,M \leq 59
  • X\neq M
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

X H M

Output

Print the answer as an integer.


Sample Input 1

30 14 10

Sample Output 1

20

It is 14:10 now. The next bus departs at 14:30, which is 20 minutes from now.


Sample Input 2

12 23 30

Sample Output 2

42

It is 23:30 now. The next bus departs at 0:12 on the next day, which is 42 minutes from now.


Sample Input 3

1 17 34

Sample Output 3

27