#include <bits/stdc++.h>
using namespace std;
string p, s;
int k;
vector<int> sol;
bool hihasol = false;
void prueba(int num1) {
  vector<int> newsol(k, 0);
  int i1 = num1 - 1;
  for (int ik = k - 1; ik >= 0; ik--) {
    int ip = ik;
    int is = i1;
    while (ip < int(p.size()) and is < int(s.size()) and p[ip] == s[is]) {
      ip += k;
      is += num1;
    }
    if (ip < int(p.size()) or is < int(s.size())) {
    } else {
      newsol[ik] = 1;
      i1--;
      if (i1 < 0) {
        if (not hihasol or newsol < sol) {
          sol = newsol;
          hihasol = true;
        }
        return;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  for (int num1 = 1; num1 <= min(k, int(s.size())); num1++) prueba(num1);
  if (not hihasol) {
    cout << 0 << endl;
  } else {
    for (int i = 0; i < k; i++) cout << sol[i];
    cout << endl;
  }
}
