#include <bits/stdc++.h>
using namespace std;
char p[1000010], s[1010], ans[10010], Ans[10010];
int n, m, k;
inline void updata() {
  bool better = 0;
  for (int i = 1; i <= k; i++)
    if (ans[i] != Ans[i]) {
      better = ans[i] < Ans[i];
      break;
    }
  if (better)
    for (int i = 1; i <= k; i++) Ans[i] = ans[i];
}
int main() {
  gets(p + 1);
  gets(s + 1);
  scanf("%d", &k);
  n = strlen(p + 1), m = strlen(s + 1);
  if (m > n) {
    puts("0");
    return 0;
  }
  Ans[1] = 127;
  int cnt = 14;
  for (int cnt = 1; cnt <= min(k, m); cnt++) {
    int now = cnt;
    bool find = 0;
    for (int i = 1; i <= k; i++) ans[i] = '0';
    for (int i = k; i >= 1; i--) {
      bool flag = 1;
      for (int j = 0; j <= max((m - now) / cnt, (n - i) / k); j++)
        if (s[now + j * cnt] != p[i + j * k]) {
          flag = 0;
          break;
        }
      if (flag) {
        now--;
        ans[i] = '1';
        if (!now) {
          find = 1;
          break;
        }
      }
    }
    if (find) updata();
  }
  if (Ans[1] == 127) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= k; i++) printf("%c", Ans[i]);
  return 0;
}
