#include <bits/stdc++.h>
using namespace std;
char ch1[1000006];
char ch[205];
char tmp[2005];
int main() {
  int k;
  gets(ch1);
  gets(ch);
  cin >> k;
  int len = strlen(ch1);
  int n = strlen(ch);
  int fake = -1;
  if (k > len) {
    fake = k;
    k = len;
  }
  int count = len / k;
  string ans = "";
  for (int cnt = 1; cnt <= n; cnt++)
    if (count * cnt <= n && n - count * cnt <= cnt) {
      int now = cnt, lth = 0;
      for (int i = k - 1; i >= 0; i--) {
        if (now == 0) {
          tmp[lth++] = '0';
          continue;
        }
        int flag = 1, s1 = i, s2 = now - 1;
        while (s1 < len && s2 < n) {
          if (ch1[s1] != ch[s2]) {
            flag = 0;
            break;
          }
          s1 += k;
          s2 += cnt;
        }
        if (s1 < len || s2 < n) flag = 0;
        if (flag)
          tmp[lth++] = '1', now--;
        else
          tmp[lth++] = '0';
      }
      if (now == 0) {
        assert(lth == k);
        reverse(tmp, tmp + lth);
        string t(tmp);
        if (ans == "" || ans > t) ans = t;
      }
    }
  if (ans == "")
    cout << 0 << endl;
  else {
    cout << ans;
    if (fake != -1)
      for (int i = 0; i < fake - k; i++) cout << 0;
    cout << endl;
  }
}
