#include <bits/stdc++.h>
using namespace std;
const int MAX = 1001000;
const int MIN = 2220;
char str[MAX], ptr[MIN];
int k, n, m, p;
string solve(int ones) {
  string ret(k, '0');
  int temp = ones;
  for (int i = k - 1; ~i && ones; --i) {
    bool flag = true;
    for (int j = 0; j < p; j++)
      flag &= (str[j * k + i] == ptr[j * temp + ones - 1]);
    if (flag) ret[i] = '1', --ones;
  }
  return (ones) ? string(MIN, '1') : ret;
}
int main() {
  cin.getline(str, MAX);
  cin.getline(ptr, MIN);
  scanf("%d", &k);
  n = strlen(str);
  m = strlen(ptr);
  p = (n + k - 1) / k;
  int ones = 1;
  string ans = string(MIN, '1');
  if (k >= n)
    ans = solve(m);
  else
    while (ones * (p - 1) <= m) {
      if (m - ones * (p - 1) <= ones) ans = min(ans, solve(ones));
      ones++;
    }
  cout << ((ans == string(MIN, '1')) ? string("0") : ans) << endl;
  return 0;
}
