#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int k;
  string p, s, ans = "";
  bool flag = false;
  getline(cin, p);
  getline(cin, s);
  cin >> k;
  int n = p.length(), m = s.length();
  for (int l = 1; l <= m; ++l) {
    int cnt = 0;
    string checker = "";
    for (int i = (k - 1); i >= 0; --i) {
      if (i >= n || cnt == l)
        checker.push_back('0');
      else {
        bool temp = true;
        int nei = l - cnt - 1, it;
        for (it = 0; nei < m; nei += l, ++it) {
          int pos = i + it * k;
          if (pos >= n || p[pos] != s[nei]) {
            temp = false;
            break;
          }
        }
        int pos = i + it * k;
        if (pos < n && nei >= m) temp = false;
        if (temp) {
          cnt++;
          checker.push_back('1');
        } else
          checker.push_back('0');
      }
    }
    if (l == cnt) {
      reverse(checker.begin(), checker.end());
      if (!flag || checker < ans) {
        ans = checker;
        flag = true;
      }
    }
  }
  if (ans == "") ans = "0";
  cout << ans << endl;
  return 0;
}
