#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1000000007;
int modpow(int x, int y, int md) {
  if (y == 0) return 1;
  int ret = modpow(x, y >> 1, md);
  ret = (long long)ret * ret % md;
  if (y & 1) ret = (long long)ret * x % md;
  return ret;
}
int fail[1000005];
int cnt1, cnt0;
string s, t;
void build(string& p) {
  int len = p.size(), j = fail[0] = -1;
  for (int i = 1; i <= len; i++) {
    while (j >= 0 && p[j] != p[i - 1]) j = fail[j];
    fail[i] = ++j;
  }
}
void ed(string& s, int cnt1, int cnt2) {
  for (int i = 0; i < cnt1; i++) s.push_back('1');
  for (int i = 0; i < cnt2; i++) s.push_back('0');
  cout << s << endl;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> s >> t;
  build(t);
  if (s.size() < t.size())
    cout << s << endl;
  else {
    string ans = "";
    for (int i = 0; i < s.size(); i++)
      cnt1 += (s[i] == '1'), cnt0 += (s[i] == '0');
    int pos = 1;
    for (int i = 0; i < s.size(); i++) {
      if ((t[pos - 1] == '1' ? --cnt1 : --cnt0) < 0) {
        ed(ans, cnt1 + (t[pos - 1] == '1'), cnt0 + (t[pos - 1] == '0'));
      }
      ans.push_back(t[pos - 1]);
      pos = (pos != t.size() ? pos + 1 : fail[pos] + 1);
    }
    cout << ans << endl;
  }
  return 0;
}
