func_code_string: #include <bits/stdc++.h>   using namespace std;   int b, d, ans, l, h;   char a[105], c[105];   bool letter[30];   int lena, lenc;   int ll[105], yy[105];   char aa[105 * 105];   inline int ok() {     memset(letter, 0, sizeof(letter));     for (char *p = a; *p; ++p) letter[*p -  a ] = 1;     for (char *p = c; *p; ++p)       if (letter[*p -  a ] == 0) return 0;     return 1;   }   inline int init() {     for (int i = 0; i < 105; ++i) strcpy(aa + i * lena, a);     for (int i = 0; i < lena; ++i) {       char *p = aa + i, *q = c;       while (*p && *q) {         while (*p && *p != *q) ++p;         if (*p != *q) return 0;         ++p, ++q;       }       if (*q != 0) return 0;       ll[i] = p - (aa + i);       yy[i] = (p - aa) % lena;     }     return 1;   }   inline int test(int p) {     p = p * d;     long long pos = 0;     long long vst[105], cnt[105];     memset(vst, -1, sizeof(vst));     for (int i = 0; i < p; ++i) {       if (pos >= lena * b) return 0;       if (vst[pos % lena] > -1) {         long long tmp = pos - vst[pos % lena];         long long tem = i - cnt[pos % lena];         pos += tmp * ((p - i) / tem);         i = (p - i) / tem * tem + i - 1;         memset(vst, -1, sizeof(vst));         continue;       }       if (i) {         vst[pos % lena] = pos;         cnt[pos % lena] = i;       }       pos += ll[pos % lena];     }     if (pos - 1 >= lena * b) return 0;     return 1;   }   int main(int argc, char **argv) {     scanf( %d%d , &b, &d);     scanf( %s%s , a, c);     lena = strlen(a), lenc = strlen(c);     if (!ok() || !init())       puts( 0 );     else {       ans = 0, l = 1, h = lena * b / (lenc * d);       while (l <= h) {         int mid = (l + h) >> 1;         if (test(mid))           ans = mid, l = mid + 1;         else           h = mid - 1;       }       printf( %d n , ans);     }     return 0;   }   