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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import java.util.StringTokenizer;

public class B {

	private void solve() throws IOException {
		int b = nextInt();
		int d = nextInt();
		char[] a = nextToken().toCharArray();
		char[] c = nextToken().toCharArray();
		
		long[][] A = new long[a.length][c.length];
		long[][] C = new long[a.length][c.length];
		long aa = 1;
		long cc = 1;
		int pa = 0;
		int pc = 0;
		while (true) {
			if (A[pa][pc] != 0) {
				if (C[pa][pc] == cc) {
					println(0);
					return;
				} else {
					break;
				}
			}
			
			
			A[pa][pc] = aa;
			C[pa][pc] = cc;
			if (a[pa] == c[pc]) {
				pc++;
				if (pc == c.length) {
					pc = 0;
					cc++;
				}
			}
			pa++;
			if (pa == a.length) {
				pa = 0;
				aa++;
			}
			
			if (aa == b + 1) {
				println((cc - 1) / d);
				return;
			}
		}
		
		long da = aa - A[pa][pc];
		long dc = cc - C[pa][pc];
		long k = (b - aa) / da;
		aa += k * da;
		cc += k * dc;
		
		while (true) {
			if (a[pa] == c[pc]) {
				pc++;
				if (pc == c.length) {
					pc = 0;
					cc++;
				}
			}
			pa++;
			if (pa == a.length) {
				pa = 0;
				aa++;
			}
			
			if (aa == b + 1) {
				println((cc - 1) / d);
				return;
			}
		}
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	private double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new B().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}