Jamie and Alarm Snooze

题意翻译

题目描述 Jamie非常喜欢睡觉。一天,他决定要在hh:mm的时候起床。然而,他也非常讨厌起床,所以他想把闹钟设置在一个幸运的时间。接着他按下一个神奇的按钮(贪睡按钮),它可以使闹钟在x分钟后响,直到hh:mm。现在,他想知道他至少要按多少次贪睡按钮。 若hh:mm中包含数字7,则它是幸运的,其它时间都不是幸运的。比如,13:07,17:27是幸运的,00:48,21:34则不是。 注意:闹钟设置的时间和hh:mm不一定要在同一天,Jamie的闹钟是24小时制的,在23:59后是00:00。 输入输出格式 输入: 第一行:x; 第二行:hh mm(中间有一个空格)(00≤hh≤23,00≤mm≤59)。 输出: 仅一行:Jamie最少需要按下神奇按(hai)钮(luo)的次数。 说明 在第一个样例中,Jaime需要在11:23起床。所以他可以将闹钟设置在11:17,并按下两次贪睡按钮。 在第二个样例中,Jaime可以直接将闹钟设置在01:07,因为它本身就是幸运的。

题目描述

Jamie loves sleeping. One day, he decides that he needs to wake up at exactly $ hh:mm $ . However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every $ x $ minutes until $ hh:mm $ is reached, and only then he will wake up. He wants to know what is the smallest number of times he needs to press the snooze button. A time is considered lucky if it contains a digit ' $ 7 $ '. For example, $ 13:07 $ and $ 17:27 $ are lucky, while $ 00:48 $ and $ 21:34 $ are not lucky. Note that it is not necessary that the time set for the alarm and the wake-up time are on the same day. It is guaranteed that there is a lucky time Jamie can set so that he can wake at $ hh:mm $ . Formally, find the smallest possible non-negative integer $ y $ such that the time representation of the time $ x·y $ minutes before $ hh:mm $ contains the digit ' $ 7 $ '. Jamie uses 24-hours clock, so after $ 23:59 $ comes $ 00:00 $ .

输入输出格式

输入格式


The first line contains a single integer $ x $ ( $ 1<=x<=60 $ ). The second line contains two two-digit integers, $ hh $ and $ mm $ ( $ 00<=hh<=23,00<=mm<=59 $ ).

输出格式


Print the minimum number of times he needs to press the button.

输入输出样例

输入样例 #1

3
11 23

输出样例 #1

2

输入样例 #2

5
01 07

输出样例 #2

0

说明

In the first sample, Jamie needs to wake up at 11:23. So, he can set his alarm at 11:17. He would press the snooze button when the alarm rings at 11:17 and at 11:20. In the second sample, Jamie can set his alarm at exactly at 01:07 which is lucky.