#include <bits/stdc++.h>
using namespace std;
template <typename T>
using vc = vector<T>;
using pii = pair<long long, long long>;
void xmax(long long& a, long long b) { a = max(a, b); }
void xmin(long long& a, long long b) { a = min(a, b); }
void print(vc<long long>& a, string second) {
  cerr << "prinitng " << second << ": ";
  for (long long i = 0; i < a.size(); i++) {
    cerr << a[i] << " ";
  }
  cerr << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string p, second;
  getline(cin, p);
  getline(cin, second);
  long long n;
  cin >> n;
  long long have_sol = -1;
  vector<long long> cur_sol;
  for (long long i = 1; i <= second.size(); i++) {
    vector<long long> sol(n);
    long long index = i - 1;
    for (long long j = n - 1; j >= 0 && index >= 0; j--) {
      bool flag = true;
      if (j >= p.size() ||
          (second.size() - index - 1) / i != (p.size() - j - 1) / n)
        flag = false;
      for (long long anz = 0; (anz * i) + index < second.size() && flag;
           anz++) {
        assert(anz * n + j < p.size());
        if (second[anz * i + index] != p[anz * n + j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        sol[j] = 1;
        index--;
      }
    }
    if (index == -1) {
      if (have_sol == -1) {
        have_sol = 1;
        cur_sol = sol;
      } else {
        for (long long i = 0; i < sol.size(); i++) {
          if (cur_sol[i] > sol[i]) {
            cur_sol = sol;
            break;
          }
          if (sol[i] > cur_sol[i]) break;
        }
      }
    }
  }
  if (have_sol == -1) {
    cout << "0\n";
  } else {
    for (long long i = 0; i < n; i++) {
      cout << cur_sol[i];
    }
    cout << "\n";
  }
}
