Let's introduce the designation <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/67a1d1d8bf722172a43f9417e83a8026881355d4.png" style="max-width: 100.0%;max-height: 100.0%;"/>, 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* &gt; 0), that [*q*, *p*] can be obtained from string *w*.
The first line contains two integers *b*, *d* (1 ≤ *b*, *d* ≤ 10<sup class="upper-index">7</sup>). 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.
import math


def a_can_from_b(a, b):
    pt = 0
    for chr in a:
        try:
            while b[pt] != chr:
                pt += 1
        except IndexError:
            return False
    return True



class CodeforcesTask314BSolution:
    def __init__(self):
        self.result = ''
        self.b_d = []
        self.a = ''
        self.c = ''

    def read_input(self):
        self.b_d = [int(x) for x in input().split(" ")]
        self.a = input()
        self.c = input()

    def process_task(self):
        left = 1
        right = math.ceil(self.b_d[0] / self.b_d[1])
        while right - left > 1:

            mid = left + (right - left) // 2
            #print(left, right, mid)
            if a_can_from_b(self.c * (self.b_d[1] * mid), self.a * self.b_d[0]):
                left = mid
            else:
                right = mid
        self.result = str(left)

    def get_result(self):
        return self.result


if __name__ == "__main__":
    Solution = CodeforcesTask314BSolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())
