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.

Examples

Input

3
11 23


Output

2


Input

5
01 07


Output

0

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.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static final long M = 1000000007;

    public static void main(String args[]) {

        FastReader io = new FastReader();

       int x = io.nextInt();

       String s = io.nextLine();
        int h = 0;
        for(int i = 0;i < 2;i++){
            h += (s.charAt(i) - '0')*Util.exp(10,1 - i);
        }
        int m = 0;
        for(int i = 3;i < 5;i++){
            m += (s.charAt(i) - '0')*Util.exp(10,4 - i);
        }
        int count = 0;

        int time = h*60 + m;

//        System.out.println(h+" "+m);
        boolean flag = false;
        while (time >= 0){
            int hh = time/60;
            int mm = time%60;
//            System.out.println(hh + " "+ mm);
            while (hh > 0){
                if(hh%10 == 7){
                    flag = true;
                    break;
                }
                hh = hh/10;
            }
            if(flag)break;
            while (mm > 0){
                if(mm%10 == 7){
                    flag = true;
                    break;
                }
                mm = mm/10;
            }

            if(flag)break;

            time = time - x;

            if(time <= 0){
                time += 24*60;
            }
            count++;
        }

        System.out.print(count);

    }
}

class Solver{
    static final long MAX = 10000000000L;

    public int solve(int n,int k,int z,int a[]){
        int pre[] = new int[n];

        pre[0] = a[0];

        for(int i = 1;i < n;i++){
            pre[i] = a[i] + pre[i - 1];
        }
        int maxsum[] = new int[n];
        maxsum[1] = 1;
        for(int i = 2;i < n;i++){
            if(a[i] + a[i - 1] >= a[maxsum[i - 1]] + a[maxsum[i - 1] - 1] ){
                maxsum[i] = i;
            }
            else{
                maxsum[i] = maxsum[i - 1];
            }
        }
        int ans = pre[k];

//        System.out.println(ans);

        for(int i = 0;i <= z && k - 2*i >= 0;i++){
            if(i == 0)continue;

            int j = maxsum[k - 2*i + 1];

            int total = pre[k - 2*i] + i*(a[j - 1] + a[j]);

//            System.out.println(total);
            ans = Math.max(ans,total);

        }

        return ans;
    }


}

class Pair{
    char u,v;
    Pair(char u,char v){
        this.u = u;
        this.v = v;
    }
}

class CharStack {
    final StringBuilder sb = new StringBuilder();

    public void push(char ch) {
        sb.append(ch);
    }

    public char pop() {
        int last = sb.length() -1;
        char ch= sb.charAt(last);
        sb.setLength(last);
        return ch;
    }

    public int size() {
        return sb.length();
    }

    public boolean empty(){
        return (sb.length() == 0);
    }

    public char peek(){
        return sb.charAt(sb.length() - 1);
    }
    public  void  show(){
        System.out.println(sb);
    }
    public char[] get(){
        return  sb.toString().toCharArray();
    }
}

class DSU{
    int parent[] = new int[26];

    DSU(){
        for(int i = 0;i < 26; i++){
            parent[i] = -1;
        }
    }

    int getParent(int u){
        if(this.parent[u] == -1)
            return u;

        parent[u] = getParent(parent[u]);

        return parent[u];
    }

    void makeParent(int u,int v){
        int pu = getParent(u);
        int pv = getParent(v);

        parent[pu] = pv;
    }


}

class Util{
    static  final  long M = 998244353;
    static long modexp(long n,long m){
        if(m==0)
            return 1;
        else if(m==1)
            return n;
        else{
            long p = modexp(n,m/2);

            if(m%2==1)
                return (((p*p)%M)*n)%M;
            else
                return (p*p)%M;
        }
    }

    static  long exp(long n,long m){
        if(m == 0)
            return 1;
        if(m == 1)
            return n;

        long p = exp(n,m/2);

        if(m%2 == 1)
            return p*p*n;
        else
            return p*p;
    }

    static long gcd(long a,long b){
        if(a==0)
            return b;

        return gcd(b%a,a);
    }

    static long inv(long n){
        return modexp(n,M-2);
    }

    static long lcm(long a,long b){
        return a*b/gcd(a,b);
    }
    static long factorial(long fact[],long n){
        fact[0]=1;
        fact[1]=1;

        long prod = 1;

        for(int i = 2;i <= n;i++){
            prod = (prod*i)%M;

            fact[i] = prod;
        }

        return prod;
    }

    static boolean isPrime(long n){
        for(int i = 2;i*i <= n;i++){
            if(n%i == 0)
                return false;
        }
        return true;
    }
}

class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}