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.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author K0T
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    static final int C = 2;

    int n, m;
    String s1, s2;

    int[] go;
    int[][] next;

    public void solve(int testNumber, InputReader scn, PrintWriter pw) {
        n = scn.nextInt();
        m = scn.nextInt();
        s1 = scn.next();
        s2 = scn.next();
        next = new int[30][(int) s1.length() + C];
        for (int i = 0; i < 26; i++) {
            next[i][s1.length()] = -1;
        }
        for (int i = (int) s1.length() - 1; i >= 0; --i) {
            for (int j = 0; j < 26; j++) {
                next[j][i] = next[j][i + 1];
            }
            int myCode = (int) s1.charAt(i) - (int) ('a');
            next[myCode][i] = i;
        }
        go = new int[s1.length() + C];
        for (int i = 0; i < s1.length(); i++) {
            go[i] = dfs(i, 0);
        }
        int have = s1.length() * n;
        int used = 0;
        int pos = 0;
        int cnt = 0;
        boolean[] was = new boolean[s1.length() + C];
        int[] prev = new int[s1.length() + C];
        int[] res = new int[s1.length() + C];
        Arrays.fill(was, false);
        Arrays.fill(prev, 0);
        Arrays.fill(res, 0);
        boolean take = false;
        while (true) {
            if (go[pos] == -1) {
                break;
            }
            if (was[pos] == true && take == false) {
                take = true;
                int addRes = cnt - res[pos];
                int addUsed = used - prev[pos];
                int moves = (have - used) / addUsed;
                cnt += (moves * addRes);
                used += (moves * addUsed);
            }
            was[pos] = true;
            prev[pos] = used;
            res[pos] = cnt;
            int add = go[pos];
            if (1L * add + 1L * used > 1L * have) {
                break;
            }
            used += add;
            int newPos = (pos + add) % ((int) s1.length());
            pos = newPos;
            ++cnt;
        }
        int result = cnt / m;
        pw.println(result);
    }

    private int dfs(int pos, int idx) {
        if (idx >= s2.length()) {
            return 0;
        }
        if (pos >= s1.length()) {
            return dfs(0, idx);
        }
        int myCode = (int) s2.charAt(idx) - (int) ('a');
        if (next[myCode][pos] == -1) {
            int add = s1.length() - pos;
            pos = 0;
            if (next[myCode][pos] == -1) {
                return -1;
            }
            return add + dfs(pos, idx);
        } else {
            int nxt = next[myCode][pos];
            return nxt - pos + 1 + dfs(nxt + 1, idx + 1);
        }
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

}
