Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc.

We'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain string s. For example, strings ab and aсba can be obtained from string xacbac, and strings bx and aaa cannot be obtained from it.

Sereja has two strings, w = [a, b] and q = [c, d]. He wants to find such maximum integer p (p > 0), that [q, p] can be obtained from string w.

Input

The first line contains two integers b, d (1 ≤ b, d ≤ 107). The second line contains string a. The third line contains string c. The given strings are not empty and consist of lowercase English letters. Their lengths do not exceed 100.

Output

In a single line print an integer — the largest number p. If the required value of p doesn't exist, print 0.

Examples

Input

10 3
abab
bab


Output

3
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;


public class B {

    public static void main(String[] args) throws Exception {
        new B().doit();
    }
    
    private void doit() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = null;
        
        // w = [a, b]
        // q = [c, d]
        
        st = new StringTokenizer(br.readLine());
        int b = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        String as = br.readLine().trim();
        char[] a = as.toCharArray();
        String cs = br.readLine().trim();
        char[] c = cs.toCharArray();
        
        // prevent infinite loop
        Set<Character> A = new HashSet<Character>();
        for (char x : a) { A.add(x); }
        Set<Character> C = new HashSet<Character>();
        for (char x : c) { C.add(x); }
        if (!A.containsAll(C)) {
            System.out.println(0);
            return;
        }
        
        // dc[i] number of characters of w consumed to repeat c once starting from w[i]
        int[] dc = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            int ic = 0;
            int ia = i;
            while(ic < c.length) {
                while(a[ia] != c[ic]) {
                    dc[i]++;
                    ia = (ia + 1) % a.length;
                }
                ic++;
                dc[i]++;
                ia = (ia + 1) % a.length;
            }
        }
        
        // dq[i] number of characters of w consumed to repeat q once starting from a[i]
        long[] dq = new long[a.length];

        for (int i = 0; i < a.length; i++) {
            int ia = i;
            int reps = 0;
            
            long con = 0;

            boolean[] v = new boolean[a.length];
            int[] vr = new int[a.length];
            long[] vc = new long[a.length];

            while(true) {
                if (v[ia]) {
                    int rem = d - reps;
                    int cycle = reps - vr[ia];
                    int cycles = rem / cycle;

                    con += cycles * (con - vc[ia]);
                    reps += cycles * cycle;

                    v = new boolean[a.length];
                    vr = new int[a.length];
                    vc = new long[a.length];
                }

                v[ia] = true;
                vr[ia] = reps;
                vc[ia] = con;

                if (reps >= d) {
                    break;
                }

                reps++;
                con += dc[ia];
                ia = (ia + dc[ia]) % a.length;
            }

            dq[i] = con;
        }

        // Final count
        long max = (long) a.length * b;
        
        int p = 0;
        int ia = 0;
        long con = 0;

        boolean[] v = new boolean[a.length];
        int[] vp = new int[a.length];
        long[] vc = new long[a.length];
        
        while(true) {

            // System.out.printf("p=%d, con=%d\n", p, con);
            // check cycles
            if (v[ia]) {
                int cyclep = p - vp[ia];
                long cyclec = con - vc[ia];
                
                long rem = max - con;
                int cycles = (int) (rem / cyclec);
                
                p += cyclep * cycles;
                con += cyclec * cycles;
                
                // prepare for more cycles
                v = new boolean[a.length];
                vp = new int[a.length];
                vc = new long[a.length];
                
                //System.out.printf("cycle, ia=%d, cyclec=%d, cyclep=%d, rem=%d, new_p=%d, new_con=%d\n", ia, cyclec, cyclep, rem, p, con);
            }

            v[ia] = true;
            vp[ia] = p;
            vc[ia] = con;

            // regular
            if (con + dq[ia] > max) {
                break;
            }
            
            p++;
            con += dq[ia];
            ia = (int) ((ia + dq[ia]) % (long) a.length);
        }

        System.out.println(p);
    }
    
}