#include <bits/stdc++.h>
using namespace std;
const int Maxp = 1000005, Maxs = 205, Maxk = 2005;
int len_p, len_s, k;
char p[Maxp], s[Maxs];
bool ans[Maxk], cur[Maxk], flag = 0;
int main() {
  gets(p);
  len_p = strlen(p);
  gets(s);
  len_s = strlen(s);
  scanf("%d", &k);
  memset(ans, 1, k);
  for (int tot = 1, N = len_p / k; tot <= len_s; tot++)
    if (tot * N <= len_s && tot * (N + 1) >= len_s) {
      int r = tot - 1;
      memset(cur, 0, k);
      for (int j = k - 1; j >= 0 && r >= 0; j--) {
        bool f = 1;
        for (int t = 0; t <= N && f; t++)
          f &= (t * k + j >= len_p && t * tot + r >= len_s) ||
               (t * k + j < len_p && t * tot + r < len_s &&
                s[t * tot + r] == p[t * k + j]);
        if (f) cur[j] = 1, --r;
      }
      if (r < 0) {
        int i = 0;
        flag = 1;
        while (i < k && cur[i] == ans[i]) ++i;
        if (i < k && cur[i] < ans[i]) memcpy(ans, cur, k);
      }
    }
  if (flag)
    for (int i = 0; i < k; i++) putchar(ans[i] + 48);
  else
    putchar(48);
  putchar('\n');
  return 0;
}
