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.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskB {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int b = in.readInt();
		int d = in.readInt();
		String a = in.readString();
		String c = in.readString();
		int n = a.length();
		int m = c.length();
		for (int i = 0; i < m; i ++) {
			boolean flag = false;
			for (int j = 0; j < n; j ++)
				if (a.charAt(j) == c.charAt(i)) {
					flag = true;
					break;
				}
			if (! flag) {
				out.printLine(0);
				return;
			}
		}
		int[][] next = new int[32][n * m];
		long[][] step = new long[32][n * m];
		for (int i = 0; i < n; i ++)
			for (int j = 0; j < m; j ++) {
				int k = i;
				int cnt = 1;
				while (a.charAt(k) != c.charAt(j)) {
					k = (k + 1) % n;
					cnt ++;
				}
				k = (k + 1) % n;
				next[0][i * m + j] = k * m + (j + 1) % m;
				step[0][i * m + j] = cnt;
			}
		for (int i = 1; i < 32; i ++)
			for (int j = 0; j < n * m; j ++) {
				next[i][j] = next[i - 1][next[i - 1][j]];
				step[i][j] = step[i - 1][j] + step[i - 1][next[i - 1][j]];
			}
		int cur = 0;
		int ans = 0;
		b *= n;
		for (int i = 31; i >= 0; i --) {
			if (step[i][cur] <= b) {
				b -= (int)step[i][cur];
				cur = next[i][cur];
				ans += 1 << i;
			}
		}
		out.printLine(ans / m / d);
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1000];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	private int read() {
		if (numChars == -1)
			throw new UnknownError();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new UnknownError();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9') throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuffer res = new StringBuffer();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}
}

