#include <bits/stdc++.h>
using namespace std;
string p, s, ep[2001], es[2001], ans = "233";
int slen, plen, k;
int main() {
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  slen = s.size();
  plen = p.size();
  for (int i = 0; i < plen; i++) ep[i % k] += p[i];
  for (int l = 1; l <= k; l++) {
    for (int i = 0; i < l; i++) es[i].clear();
    for (int i = 0; i < slen; i++) es[i % l] += s[i];
    int now = l - 1;
    string tmp;
    for (int i = k - 1; i >= 0; --i)
      if (now >= 0 && ep[i] == es[now])
        tmp += "1", --now;
      else
        tmp += "0";
    reverse(tmp.begin(), tmp.end());
    if (now < 0) ans = min(ans, tmp);
  }
  if (ans == "233") ans = "0";
  cout << ans << endl;
}
