#include <bits/stdc++.h>
using namespace std;
using namespace std::placeholders;
template <typename container>
vector<int> gen_kmp(container const& s) {
  vector<int> res(1, 0);
  for (int cur = 0; res.size() < s.size();) {
    if (s[res.size()] == s[cur])
      res.push_back(++cur);
    else if (cur)
      cur = res[cur - 1];
    else
      res.push_back(0);
  }
  return res;
}
string s, t;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> t;
  int cnt1 =
      (int)(count_if(s.begin(), s.end(), [](char c) { return c == '1'; }));
  int cnt0 = ((int)s.size()) - cnt1;
  auto t_kmp = gen_kmp(t);
  int cur = 0;
  for (int i = -1; ++i < ((int)s.size());) {
    if (!cnt1 or !cnt0) break;
    if (cur == ((int)t.size())) cur = t_kmp[cur - 1];
    if (t[cur++] == '1') {
      cout << '1';
      --cnt1;
    } else {
      cout << '0';
      --cnt0;
    }
  }
  cout << string(cnt1, '1') << string(cnt0, '0');
  return 0;
}
