#include <bits/stdc++.h>
using namespace std;
char s[1 << 20], t[256];
int n, m, k, a, b, d;
int hs[1 << 20], ht[512];
bool vis[2048][256];
char c[2048], r[2048];
bool rr;
bool dfs(int i, int j) {
  if (vis[i][j]) return false;
  vis[i][j] = true;
  if (i == n % k) {
    if (j != b) return false;
  }
  if (i == k) return j == d;
  c[i] = '0';
  if (dfs(i + 1, j)) return true;
  if (j < d && hs[i] == ht[j]) {
    c[i] = '1';
    if (dfs(i + 1, j + 1)) return true;
  }
  return false;
}
int main() {
  gets(s);
  gets(t);
  scanf("%d", &k);
  n = strlen(s);
  m = strlen(t);
  a = n / k;
  if (n > 400000) {
    puts("0");
    return 0;
  }
  for (int i = n - 1; i >= 0; --i)
    hs[i] = (1LL * 12721 * hs[i + k] + s[i]) % 1071251227;
  for (int _d = 1, ThxDem = 201; _d < ThxDem; ++_d) {
    d = _d;
    b = m - d * a;
    if (b < 0 || b > min(n % k, d)) continue;
    for (int i = m - 1; i >= 0; --i)
      ht[i] = (1LL * 12721 * ht[i + d] + t[i]) % 1071251227;
    memset(vis, false, sizeof(vis));
    if (dfs(0, 0)) {
      if (!rr || strncmp(c, r, k) < 0) memcpy(r, c, sizeof(r));
      rr = true;
    }
  }
  if (!rr)
    puts("0");
  else
    puts(r);
  return 0;
}
