#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 7;
string p, s, pc[maxn], sc[maxn], ans = "222";
int k;
int main() {
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  int plen = p.length();
  int slen = s.length();
  for (int i = 0; i < plen; ++i) pc[i % k] += p[i];
  for (int l = 1; l <= k; ++l) {
    for (int i = 0; i < l; ++i) sc[i].clear();
    for (int i = 0; i < slen; ++i) sc[i % l] += s[i];
    int now = l - 1;
    string lin;
    for (int i = k - 1; i >= 0; --i) {
      if (now >= 0 && pc[i] == sc[now]) {
        --now;
        lin += "1";
      } else
        lin += "0";
    }
    reverse(lin.begin(), lin.end());
    if (now < 0) ans = min(ans, lin);
  }
  if (ans == "222")
    cout << "0";
  else
    cout << ans;
  return 0;
}
