#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000 + 10;
const int NUM = 200 + 10;
char p[2000000], s[2000000];
int n;
int m;
int k;
int f[MAX][NUM], come[MAX][NUM];
char a[MAX], b[MAX];
int tota, totb;
string getAns(int Len) {
  memset(f, 0, sizeof f);
  memset(come, -1, sizeof come);
  if (n % Len > m % k || !(n / Len - m / k <= 1 && n / Len - m / k >= 0))
    return string();
  int i, j;
  f[k + 1][Len + 1] = 1;
  for (i = k; i >= 1; --i)
    for (j = Len + 1; j >= 1; --j) {
      if (f[i + 1][j]) {
        f[i][j] = 1;
        come[i][j] = 0;
        continue;
      }
      tota = 0;
      for (int c = j; c <= n; c += Len) a[++tota] = s[c];
      totb = 0;
      for (int c = i; c <= m; c += k) b[++totb] = p[c];
      int flag = (tota == totb);
      for (int c = 1; c <= tota && flag; ++c) flag &= (a[c] == b[c]);
      if (f[i + 1][j + 1] && flag) {
        f[i][j] = 1;
        come[i][j] = 1;
      }
    }
  string ans;
  int now = 1;
  if (!f[1][1]) return string();
  for ((i) = (1); (i) <= (k); ++(i)) {
    ans += char(come[i][now] + '0');
    if (come[i][now]) now++;
  }
  return ans;
}
int main() {
  int j;
  gets(p + 1);
  gets(s + 1);
  n = strlen(s + 1);
  m = strlen(p + 1);
  scanf("%d", &k);
  int tmp = k;
  k = min(k, m);
  string ans;
  for ((j) = (1); (j) <= (n); ++(j)) {
    string tmp = getAns(j);
    if (tmp.size() && (!ans.size() || tmp < ans)) ans = tmp;
  }
  if (ans.size()) {
    while ((int)ans.size() < tmp) ans += char('0');
    cout << ans << endl;
  } else
    cout << 0 << endl;
  return 0;
}
