#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int k, lenp, lens;
string p, s, p1[maxn], s1[maxn], ans;
int main() {
  ios::sync_with_stdio(false);
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  lenp = p.size();
  lens = s.size();
  for (int i = 0; i < lenp; i++) p1[i % k] += p[i];
  ans = "2";
  int maxt = min(k, lens);
  for (int i = 1; i <= maxt; i++) {
    for (int j = 0; j < i; j++) s1[j] = "";
    for (int j = 0; j < lens; j++) s1[j % i] += s[j];
    string tmp;
    int pos = i - 1;
    for (int j = k - 1; j >= 0; j--) {
      if (pos >= 0 && p1[j] == s1[pos]) {
        pos--;
        tmp += "1";
      } else {
        tmp += "0";
      }
    }
    if (pos < 0) {
      reverse(tmp.begin(), tmp.end());
      ans = min(ans, tmp);
    }
  }
  if (ans == "2")
    puts("0");
  else
    cout << ans << endl;
  return 0;
}
