{"raw_statement":[{"iden":"statement","content":"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.\n\nA 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_.\n\nNote 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_.\n\nFormally, 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'.\n\nJamie uses 24-hours clock, so after 23: 59 comes 00: 00."},{"iden":"input","content":"The first line contains a single integer _x_ (1 ≤ _x_ ≤ 60).\n\nThe second line contains two two-digit integers, _hh_ and _mm_ (00 ≤ _hh_ ≤ 23, 00 ≤ _mm_ ≤ 59)."},{"iden":"output","content":"Print the minimum number of times he needs to press the button."},{"iden":"examples","content":"Input\n\n3\n11 23\n\nOutput\n\n2\n\nInput\n\n5\n01 07\n\nOutput\n\n0"},{"iden":"note","content":"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.\n\nIn the second sample, Jamie can set his alarm at exactly at 01:07 which is _lucky_."}],"translated_statement":[{"iden":"statement","content":"Jamie 喜欢睡觉。一天，他决定必须在恰好 #cf_span[hh: mm] 醒来。然而，他讨厌醒来，因此他希望通过将闹钟设在一个 _幸运_ 的时间来减轻醒来时的痛苦。他将在每个 #cf_span[x] 分钟后按下一次睡眠按钮，直到时间到达 #cf_span[hh: mm] 时才真正醒来。他想知道他最少需要按多少次睡眠按钮。\n\n一个时间被认为是 _幸运_ 的，如果它包含数字 '#cf_span[7]'。例如，#cf_span[13: 07] 和 #cf_span[17: 27] 是 _幸运_ 的，而 #cf_span[00: 48] 和 #cf_span[21: 34] 则不是 _幸运_ 的。\n\n注意，闹钟设置的时间和醒来时间不一定在同一天。题目保证存在一个 _幸运_ 时间，使得 Jamie 能够在 #cf_span[hh: mm] 醒来。\n\n形式化地，求最小的非负整数 #cf_span[y]，使得在 #cf_span[hh: mm] 前 #cf_span[x·y] 分钟的时间表示中包含数字 '#cf_span[7]'。\n\nJamie 使用 24 小时制，因此 #cf_span[23: 59] 之后是 #cf_span[00: 00]。\n\n第一行包含一个整数 #cf_span[x] (#cf_span[1 ≤ x ≤ 60])。\n\n第二行包含两个两位数的整数 #cf_span[hh] 和 #cf_span[mm] (#cf_span[00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59])。\n\n请输出他最少需要按按钮的次数。\n\n在第一个样例中，Jamie 需要在 11:23 醒来。因此，他可以将闹钟设在 11:17。当闹钟在 11:17 和 11:20 响起时，他会按下睡眠按钮。\n\n在第二个样例中，Jamie 可以直接将闹钟设在 01:07，这是一个 _幸运_ 时间。"},{"iden":"input","content":"第一行包含一个整数 #cf_span[x] (#cf_span[1 ≤ x ≤ 60])。第二行包含两个两位数的整数 #cf_span[hh] 和 #cf_span[mm] (#cf_span[00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59])。"},{"iden":"output","content":"请输出他最少需要按按钮的次数。"},{"iden":"examples","content":"输入311 23输出2输入501 07输出0"},{"iden":"note","content":"在第一个样例中，Jamie 需要在 11:23 醒来。因此，他可以将闹钟设在 11:17。当闹钟在 11:17 和 11:20 响起时，他会按下睡眠按钮。在第二个样例中，Jamie 可以直接将闹钟设在 01:07，这是一个 _幸运_ 时间。"}],"sample_group":[],"show_order":[],"formal_statement":"Let $ x \\in \\mathbb{Z}^+ $, $ 1 \\leq x \\leq 60 $, be the snooze interval in minutes.  \nLet $ T = (h, m) $, where $ 0 \\leq h \\leq 23 $, $ 0 \\leq m \\leq 59 $, be the wake-up time in 24-hour format.\n\nDefine the time $ t_y $ as the time $ y \\cdot x $ minutes before $ T $, for non-negative integers $ y $.  \nLet $ t_y $ be represented in 24-hour format as a 4-digit string $ HHMM $, where leading zeros are included.\n\nA time is *lucky* if its string representation contains the digit '7'.\n\nFind the smallest non-negative integer $ y $ such that the string representation of $ t_y $ contains the digit '7'.\n\nNote: Time wraps around modulo 1440 (number of minutes in a day).","simple_statement":null,"has_page_source":false}