#include <bits/stdc++.h>
using namespace std;
double eps = 1e-6;
double pii = acos(-1.0);
char sp[2000004], s[405];
int k, n, m;
int ans[4005], tmp[4005];
int a[2000005], b[2000005];
bool ok = false;
int main() {
  gets(sp);
  gets(s);
  scanf("%d", &k);
  n = strlen(sp);
  m = strlen(s);
  int p = n / k;
  int q = n % k;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < k; j++) tmp[j] = 0;
    if (i * p > m && i * p + q < m) continue;
    int last = m - i * p;
    int l = i - 1;
    for (int j = k - 1; j >= 0; j--) {
      bool flag = true;
      int la = 0;
      for (int c = l; c < m; la++, c += i) {
        a[la] = s[c];
      }
      int lb = 0;
      for (int c = j; c < n; lb++, c += k) b[lb] = sp[c];
      if (la != lb) flag = false;
      if (flag) {
        for (int c = 0; c < la; c++)
          if (b[c] != a[c]) {
            flag = false;
            break;
          }
      }
      if (flag) {
        l--;
        tmp[j] = 1;
        if (l < 0) break;
      } else
        tmp[j] = 0;
    }
    if (l < 0) {
      bool flag = false;
      for (int j = 0; j < k; j++) {
        if (tmp[j] < ans[j]) {
          flag = true;
          break;
        } else if (tmp[j] > ans[j]) {
          flag = false;
          break;
        }
      }
      if (flag || !ok)
        for (int j = 0; j < k; j++) ans[j] = tmp[j];
      ok = true;
    }
  }
  if (!ok)
    puts("0");
  else
    for (int i = 0; i < k; i++) printf("%d", ans[i]);
  return 0;
}
