#include <bits/stdc++.h>
using namespace std;
char p[1000000 + 1], s[256];
int plen, slen;
int k;
vector<char> gives[2000 + 1];
vector<char> getfrom[2000 + 1];
string res = "999";
int main() {
  gets(p);
  gets(s);
  plen = strlen(p);
  slen = strlen(s);
  scanf("%d", &k);
  for (int i = 0; i < k; i++)
    for (int j = i; j < plen; j += k) gives[i].push_back(p[j]);
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < k; j++) getfrom[j].clear();
    for (int j = 0; j < slen; j++) getfrom[j % i].push_back(s[j]);
    string cand(k, '0');
    int cur = i - 1;
    for (int j = k - 1; j >= 0 && cur >= 0; j--)
      if (gives[j] == getfrom[cur]) {
        cand[j] = '1';
        cur--;
      }
    if (cur < 0) res = min(res, cand);
  }
  printf("%s\n", res == "999" ? "0" : res.c_str());
  return 0;
}
