#include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 1000005;
int n, m, kk;
string pp[N], ss[N], p, s;
string process(int cnt1) {
  string ret;
  for (int i = 0; i < cnt1; i++) ss[i].clear();
  for (int i = 0; i < m; i++) ss[i % cnt1] += s[i];
  int pos = cnt1 - 1;
  for (int i = kk - 1; i >= 0; --i)
    if (pos >= 0 && pp[i] == ss[pos])
      --pos, ret += '1';
    else
      ret += '0';
  if (pos >= 0) ret = "";
  reverse(ret.begin(), ret.end());
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  getline(cin, p);
  getline(cin, s);
  cin >> kk;
  n = p.size();
  m = s.size();
  for (int i = 0; i < n; i++) pp[i % kk] += p[i];
  string res;
  for (int i = 1; i <= kk && i <= n; i++) {
    auto t = process(i);
    if (t == "") continue;
    if (res == "" || res > t) res = t;
  }
  if (res == "")
    cout << 0 << endl;
  else
    cout << res << endl;
  return 0;
}
