#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e9;
string gogo[3000];
void parse(string &s, int fr, int k, int len) {
  int i = fr;
  gogo[fr] = "";
  while ((int)(gogo[fr]).size() <= len && i < (int)(s).size()) {
    gogo[fr] += s[i];
    i += k;
  }
}
bool is(string &s, int fr, int delta, string &with) {
  for (int i = 0; i < ((int)(with).size()); i++) {
    if (fr >= (int)(s).size()) return false;
    if (s[fr] != with[i]) return false;
    fr += delta;
  }
  return fr >= (int)(s).size();
}
int main() {
  string p, s;
  getline(cin, p);
  getline(cin, s);
  int n = (int)(p).size(), m = (int)(s).size();
  int k;
  cin >> k;
  for (int i = 0; i < (k); i++) {
    gogo[i] = "";
    for (int j = 0; j < (m + 1); j++) {
      gogo[i] += 'a';
    }
  }
  for (int i = 0; i < (min(k, n)); i++) {
    parse(p, i, k, m);
  }
  string out = "";
  for (int add = 0; add <= m; add++) {
    int now = k;
    string hihi = "";
    for (int i = 0; i < (k); i++) hihi += '0';
    bool can = false;
    for (int i = add; i >= 0; i--) {
      now--;
      for (; now >= 0; now--) {
        if (is(s, i, add + 1, gogo[now])) {
          hihi[now] = '1';
          break;
        }
      }
      if (now < 0) {
        can = true;
        break;
      }
    }
    if (can) continue;
    if ((int)(out).size() == 0 || hihi < out) out = hihi;
  }
  if ((int)(out).size() == 0)
    cout << 0;
  else
    cout << out;
}
