#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int lps[N];
string s, t;
void build_kmp(string &s) {
  for (int i = (0); i <= (((int)(s).size()) - 1); i += (+1))
    if (i > 0) {
      int j = lps[i - 1];
      while (j > 0 && s[i] != s[j]) {
        j = lps[j - 1];
      }
      lps[i] = j + (s[i] == s[j]);
    }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
  cin >> s >> t;
  build_kmp(t);
  int period = (int)(t).size() - lps[(int)(t).size() - 1];
  string nt = t.substr((int)(t).size() - period);
  string ans = t;
  while ((int)(ans).size() < (int)(s).size()) {
    ans += nt;
  }
  ans.resize((int)(s).size());
  int s0 = 0;
  for (int i = (0); i <= (((int)(s).size()) - 1); i += (+1)) {
    s0 += s[i] == '0';
  }
  int s1 = (int)(s).size() - s0;
  for (int i = (0); i <= (((int)(ans).size()) - 1); i += (+1)) {
    if (ans[i] == '0' && --s0 < 0) {
      ans[i] = '1';
    }
    if (ans[i] == '1' && --s1 < 0) {
      ans[i] = '0';
    }
  }
  cout << ans << '\n';
  return 0;
}
