#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     string a, c;     int b, d, p;     int pos[110];     p = 0;     cin >> b >> d;     cin >> a;     cin >> c;     int t = 0, la, lc;     la = a.length();     lc = c.length();     int k = 0;     for (int i = 0; i < lc; i++) {       k = 0;       for (int j = 0; j < la; j++)         if (a[j] == c[(i + k) % lc]) k++;       pos[i] = k;     }     int sum = 0;     int j = 0;     for (int i = 0; i < b; i++) {       sum += pos[j];       j = (j + pos[j]) % lc;     }     sum /= lc;     p = sum / d;     cout << p << endl;     return 0;   }   