#include <bits/stdc++.h>
using namespace std;
string p, s, tmp, ans, p1[2010], s1[2010];
int k, len1, len2, now;
int main() {
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  len1 = p.size();
  len2 = s.size();
  for (int i = 0; i < len1; i++) {
    p1[i % k] += p[i];
  }
  ans = "9";
  for (int i = 1; i <= min(len1, k); i++) {
    for (int j = 0; j < i; j++) {
      s1[j] = "";
    }
    for (int j = 0; j < len2; j++) {
      s1[j % i] += s[j];
    }
    now = i - 1;
    tmp = "";
    for (int j = k - 1; j >= 0; j--) {
      if (now >= 0 && s1[now] == p1[j]) {
        now--;
        tmp += "1";
      } else {
        tmp += "0";
      }
    }
    if (now < 0) {
      reverse(tmp.begin(), tmp.end());
      ans = min(ans, tmp);
    }
  }
  if (ans == "9") {
    cout << "0" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
