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.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class SerajaAndPeriods {
    static int len;

    public static long[] mul(long[] a, long[] b) {
        long[] result = new long[len];
        for (int i = 0; i < a.length; i++)
            result[i] = a[i] + b[(int) ((i + a[i]) % len)];
        return result;
    }

    public static long[] power(long[] b, long e) {
        long[] result = new long[len];
        while (e > 0) {
            if (e % 2 != 0) {
                result = mul(result, b);
            }
            b = mul(b, b);
            e >>= 1;
        }
        return result;
    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer strtok;
        strtok = new StringTokenizer(in.readLine());
        int b = Integer.parseInt(strtok.nextToken());
        int d = Integer.parseInt(strtok.nextToken());
        strtok = new StringTokenizer(in.readLine());
        char[] w = strtok.nextToken().toCharArray();
        strtok = new StringTokenizer(in.readLine());
        char[] p = strtok.nextToken().toCharArray();
        int[][] next = new int[w.length + 1][];
        next[w.length] = new int[26];
        Arrays.fill(next[w.length], -1);
        for (int i = w.length - 1; i >= 0; i--) {
            next[i] = next[i + 1].clone();
            next[i][w[i] - 'a'] = i;
        }
        TreeSet<Character> C = new TreeSet<Character>();
        for (int i = 0; i < w.length; i++)
            C.add(w[i]);
        for (int i = 0; i < p.length; i++) {
            if (!C.contains(p[i])) {
                System.out.println(0);
                return;
            }
        }
        len = w.length;
        long[] required = new long[w.length];
        for (int i = 0; i < w.length; i++) {
            int current = i;
            int consumed = 0;
            for (int j = 0; j < p.length; j++) {
                if (next[current][p[j] - 'a'] == -1) {
                    consumed += w.length - current;
                    current = 0;
                    consumed += 1 + next[current][p[j] - 'a'];
                    current = next[current][p[j] - 'a'] + 1;

                } else {
                    consumed += next[current][p[j] - 'a'] - current + 1;
                    current = next[current][p[j] - 'a'] + 1;
                }
            }
            required[i] = consumed;
        }
        long have = w.length * b;
        long[] base = power(required, d);

        long lo = 0;
        long hi = (int) 1e9 + 5;
        while (hi > lo) {
            long mid = (lo + hi) / 2;

            if (power(base, mid)[0] > have)
                hi = mid;
            else
                lo = mid + 1;
        }
        System.out.println(hi - 1);
    }
}
