#include <bits/stdc++.h>
using namespace std;
int md1 = 1e9 + 7, md2 = 1e9 + 9, B = 130;
struct H {
  int x, y;
  H(int a = 0, int b = 0) : x(a), y(b) {}
  bool operator==(H o) { return x == o.x && y == o.y; }
  void operator+=(char c) {
    x = ((long long)x * B + c) % md1;
    y = ((long long)y * B + c) % md2;
  }
} h[2000];
char p[1000001], s[201];
int k, n, m;
inline void no() { printf("0\n"), exit(0); }
H gth(int i, int o) {
  H h;
  for (int j = i; j < m; j += o) h += s[j];
  return h;
}
string gt(int o) {
  string an(k, '0');
  int z = o;
  for (int i = k - 1; i >= 0 && z; --i)
    if (gth(z - 1, o) == h[i]) an[i] = '1', --z;
  if (z) return string();
  return an;
}
int main() {
  gets(p);
  gets(s);
  scanf("%d", &k);
  n = strlen(p);
  m = strlen(s);
  if (m > n) no();
  for (int i = 0; i < (int)(k); ++i)
    for (int j = i; j < n; j += k) h[i] += p[j];
  int z = (n + k - 1) / k;
  int a = (m + z - 1) / z, b = z - 1 ? m / (z - 1) : a;
  string an;
  for (int i = a; i < (int)(b + 1); ++i) {
    string t = gt(i);
    if (!t.empty() && (an.empty() || t < an)) an.swap(t);
  }
  if (an.empty()) no();
  printf("%s\n", an.c_str());
}
