#include <bits/stdc++.h>
using namespace std;
string p, s;
vector<long long int> key, solution;
long long int k;
bool dp[2020][200];
bool ok(long long int c, long long int cnt, long long int idx) {
  for (int i = 0; i < ((int)(((long long int)(p).size()) / k + 1)); i++) {
    if (i * c + cnt < ((long long int)(s).size()) &&
        s[i * c + cnt] != p[i * k + idx])
      return false;
  }
  long long int mojis = ((long long int)(p).size()) / k * c;
  if (mojis > ((long long int)(s).size())) return false;
  if (idx < ((long long int)(p).size()) % k) {
    if (mojis + cnt + 1 > ((long long int)(s).size()) ||
        mojis + c < ((long long int)(s).size()))
      return false;
  } else {
    if (mojis + cnt < ((long long int)(s).size())) return false;
  }
  return true;
}
bool check(long long int c) {
  solution.clear();
  for (int i = 0; i < ((int)(k)); i++) key[i] = 0;
  long long int count = c - 1;
  for (int i = k - 1; i >= 0; i--) {
    if (ok(c, count, i)) {
      solution.push_back(i);
      count--;
      if (count < 0) {
        for (int j = 0; j < ((int)(c)); j++) key[solution[j]] = 1;
        return true;
      }
    }
  }
  return false;
}
int main() {
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  for (int i = 0; i < ((int)(k)); i++) key.push_back(0);
  string candidate = "";
  for (int i = 0; i < ((int)(k)); i++) candidate += " ";
  vector<string> ans;
  for (int i = (int)(1); i < ((int)(min(k, ((long long int)(s).size())) + 1));
       i++) {
    if (check(i)) {
      for (int j = 0; j < ((int)(k)); j++)
        candidate[j] = (key[j] == 1 ? '1' : '0');
      ans.push_back(candidate);
    }
  }
  if (((long long int)(ans).size()) == 0)
    cout << 0 << endl;
  else {
    sort((ans).begin(), (ans).end());
    cout << ans[0] << endl;
  }
  return 0;
}
