#include <bits/stdc++.h>
using namespace std;
const int M = 1000000 + 10;
int ans[2000 + 10];
int main() {
  time_t t_start, t_end;
  t_start = clock();
  string p, s;
  getline(cin, p);
  getline(cin, s);
  int plen = p.length();
  int slen = s.length();
  int k;
  cin >> k;
  int origink = k;
  int q = plen / k;
  int r = plen % k;
  if (q == 0) {
    k = plen;
    q = plen / k;
    r = plen % k;
  }
  int qs = slen / q;
  int rs = slen % q;
  if (r == 0) {
    if (rs == 0) {
      int col = k - 1;
      int num = qs - 1;
      while (col >= 0 && num >= 0) {
        int cnt = 0;
        for (int i = 0; i < q; i++) {
          int idq = col + i * k;
          int ids = num + i * qs;
          cnt = cnt + (p[idq] == s[ids]);
        }
        if (cnt == q) {
          ans[col] = 1;
          num--;
        }
        col--;
      }
      if (num < 0) {
        for (int i = 0; i < origink; i++) {
          cout << ans[i];
        }
        cout << endl;
      } else {
        cout << 0 << endl;
      }
    } else {
      cout << 0 << endl;
    }
  } else {
    bool ok = false;
    for (int rem = 0; rem <= r; rem++) {
      if (rem == 0) {
        if (slen % q == 0) {
          int col = k - 1;
          int num = qs - 1;
          while (col >= r && num >= 0) {
            int cnt = 0;
            for (int i = 0; i < q; i++) {
              int idq = col + i * k;
              int ids = num + i * qs;
              cnt = cnt + (p[idq] == s[ids]);
            }
            if (cnt == q) {
              ans[col] = 1;
              num--;
            }
            col--;
          }
          if (num < 0) {
            ok = true;
          } else {
            for (int i = 0; i < k; i++) {
              ans[i] = 0;
            }
          }
        }
      } else {
        int left1 = (q + 1) * rem;
        int right1 = (slen - left1);
        if (right1 >= 0 && right1 % q == 0) {
          int res = right1 / q;
          int tmp[2000 + 10];
          for (int i = 0; i < 2000; i++) {
            tmp[i] = 0;
          }
          int col = k - 1;
          int num = rem + res - 1;
          while (col >= r && num >= rem) {
            int cnt = 0;
            for (int i = 0; i < q; i++) {
              int idq = col + i * k;
              int ids = num + i * (rem + res);
              cnt = cnt + (p[idq] == s[ids]);
            }
            if (cnt == q) {
              tmp[col] = 1;
              num--;
            }
            col--;
          }
          if (num == rem - 1) {
            col = r - 1;
            num = rem - 1;
            while (col >= 0 && num >= 0) {
              int cnt = 0;
              for (int i = 0; i < q + 1; i++) {
                int idq = col + i * k;
                int ids = num + i * (rem + res);
                cnt = cnt + (p[idq] == s[ids]);
              }
              if (cnt == q + 1) {
                tmp[col] = 1;
                num--;
              }
              col--;
            }
            if (num < 0) {
              ok = true;
              int num0 = 0;
              for (int i = 0; i < k; i++) {
                if (ans[i] == 0) {
                  num0++;
                }
              }
              if (num0 == k) {
                for (int i = 0; i < k; i++) {
                  ans[i] = tmp[i];
                }
              } else {
                bool isless = false;
                for (int i = 0; i < k; i++) {
                  if (tmp[i] != ans[i]) {
                    isless = (tmp[i] < ans[i]);
                    break;
                  }
                }
                if (isless) {
                  for (int i = 0; i < k; i++) {
                    ans[i] = tmp[i];
                  }
                }
              }
            }
          }
        }
      }
    }
    if (!ok) {
      cout << 0 << endl;
    } else {
      for (int i = 0; i < origink; i++) {
        cout << ans[i];
      }
      cout << endl;
    }
  }
  t_end = clock();
  return 0;
}
