#include <bits/stdc++.h>
using namespace std;
const int N = 2013;
char p[1 << 20], s[205];
int k, n, m, r, i, l1, l2, e;
string y, z;
int main() {
  gets(p);
  gets(s);
  cin >> k;
  n = strlen(p);
  m = strlen(s);
  for (int i = 0; i <= k; ++i) y += "1";
  int rboud = min(m, k), cntIn = n / k, R = n % k;
  for (int d = 1; d <= rboud && cntIn * d <= m; ++d) {
    z = "";
    for (int i = 0; i <= k - 1; ++i) z += "0";
    for (i = min(n - 1, k - 1), r = d - 1; i >= 0 && r >= 0; --i) {
      l1 = m / d + (r < m % d);
      l2 = cntIn + (i < R);
      if (l1 == l2) {
        for (e = 0; e < l1 && s[r + e * d] == p[i + e * k]; ++e)
          ;
        if (e == l1) z[i] = '1', --r;
      }
    }
    if (r == -1) y = min(y, z);
  }
  if (y.size() > k)
    cout << 0;
  else
    cout << y;
  return 0;
}
