#include <bits/stdc++.h>
using namespace std;
char p[1000010];
char s[210];
int lenp, lens;
int k;
int n;
int delta;
int mem[2010][210];
int calc(int i, int j) {
  if (j >= delta) return 1;
  if (i >= k) return 0;
  int& res = mem[i][j];
  if (res != -1) return res;
  res = 0;
  res |= calc(i + 1, j);
  if (res) return res;
  bool f = 1;
  int K = j, l = i;
  for (; K < lens && l < lenp; K += delta, l += k)
    if (p[l] != s[K]) {
      f = 0;
      break;
    }
  if (f && K >= lens && l >= lenp) res |= calc(i + 1, j + 1);
  return res;
}
char ans[10000];
inline void print(int i, int j) {
  while (i < k) {
    if (calc(i, j) == calc(i + 1, j))
      ans[i] = '0';
    else {
      ans[i] = '1';
      ++j;
    }
    ++i;
  }
  ans[i] = 0;
}
int main() {
  while (gets(p)) {
    gets(s);
    scanf("%d ", &k);
    lenp = strlen(p);
    lens = strlen(s);
    n = lenp / k + (lenp % k != 0);
    int tdelta = lens / n + (lens % n != 0);
    bool f = 0;
    string str(k, '1');
    for (delta = lens; delta >= tdelta; --delta) {
      memset(mem, -1, sizeof mem);
      int res = calc(0, 0);
      f |= res;
      print(0, 0);
      if (res) {
        str = min(str, string(ans));
      }
    }
    if (!f) {
      printf("0\n");
      continue;
    }
    printf("%s\n", str.c_str());
  }
  return 0;
}
