#include <bits/stdc++.h>
using namespace std;
string p, s, ans;
int exist = false, K;
string G[2002], store[2002];
int main() {
  getline(cin, p);
  getline(cin, s);
  cin >> K;
  for (int i = 0; i < p.size(); i++) {
    G[i % K] += p[i];
  }
  for (int bit = 1; bit <= K; bit++) {
    for (int i = 0; i <= bit; i++) store[i].clear();
    for (int i = 0; i < s.size(); i++) store[i % bit] += s[i];
    string here = string(K, '0');
    int idx = bit - 1;
    for (int i = K - 1; i >= 0; i--) {
      if (idx >= 0 && G[i] == store[idx]) idx--, here[i] = '1';
    }
    if (idx >= 0) continue;
    if (!exist || here < ans) ans = here, exist = true;
  }
  if (!exist) ans = "0";
  cout << ans << endl;
  return 0;
}
