Codeforces Round 457 (Div. 2)
A
Jamie and Alarm Snooze
Codeforces
900
原题
←B →
翻译中…

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$.

翻译中…

Input

翻译中…

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$).

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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.

翻译中…

样例

Input #1
3
11 23
Output #1
2
InputCopy OutputCopy
Input #2
5
01 07
Output #2
0
InputCopy OutputCopy
题目信息
题号
916A
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。