#include <bits/stdc++.h>
using namespace std;
string p, s;
int k;
vector<string> p_part;
vector<string> part(string &t, int mod) {
  vector<string> ans(mod);
  for (int i = 0; i < t.size(); ++i) ans[i % mod].push_back(t[i]);
  return ans;
}
string answer("0");
void solve(int m) {
  vector<string> s_part = part(s, m);
  reverse(s_part.begin(), s_part.end());
  int l = 0;
  string cur_ans;
  for (int i = k - 1; i >= 0; --i) {
    if (l < m && p_part[i] == s_part[l]) {
      cur_ans.push_back('1');
      l++;
    } else
      cur_ans.push_back('0');
  }
  reverse(cur_ans.begin(), cur_ans.end());
  if (l == m)
    if (answer != "0")
      answer = min(answer, cur_ans);
    else
      answer = cur_ans;
}
bool check(string key) {
  string we_make;
  for (int i = 0; i < p.size(); ++i)
    if (key[i % k] == '1') we_make.push_back(p[i]);
  return we_make == s;
}
int main() {
  getline(cin, p);
  getline(cin, s);
  scanf(" %d", &k);
  p_part = part(p, k);
  for (int nr_bits = 1; nr_bits * max(1, (int)p.size() / k) <= s.size();
       ++nr_bits) {
    solve(nr_bits);
  }
  cout << answer << '\n';
}
