#include <bits/stdc++.h>
using namespace std;
string s, t;
int lens, lent, lena;
int cnt0s = 0;
int cnt1s = 0;
int cnt0t = 0;
int cnt1t = 0;
int cnt0a = 0;
int cnt1a = 0;
int F[500005];
int main() {
  cin >> s;
  cin >> t;
  lens = s.length();
  lent = t.length();
  bitset<500005> bits(s);
  cnt1s = bits.count();
  cnt0s = lens - cnt1s;
  bitset<500005> bitt(t);
  cnt1t = bitt.count();
  cnt0t = lent - cnt1t;
  if (cnt0s < cnt0t || cnt1s < cnt1t) {
    cout << s << endl;
    return 0;
  }
  F[0] = -1;
  for (int i = 1; i < lent; i++) {
    int j = F[i - 1];
    while ((t[j + 1] != t[i]) && (j >= 0)) j = F[j];
    if (t[j + 1] == t[i])
      F[i] = j + 1;
    else
      F[i] = -1;
  }
  string add;
  for (int i = F[lent - 1] + 1; i < lent; i++) {
    add += t[i];
  }
  lena = add.length();
  bitset<500005> bita(add);
  cnt1a = bita.count();
  cnt0a = lena - cnt1a;
  cout << t;
  cnt0s -= cnt0t;
  cnt1s -= cnt1t;
  while (cnt0s >= cnt0a && cnt1s >= cnt1a) {
    cout << add;
    cnt0s -= cnt0a;
    cnt1s -= cnt1a;
  }
  for (int i = 0; i < cnt0s; i++) {
    cout << '0';
  }
  for (int i = 0; i < cnt1s; i++) {
    cout << '1';
  }
  return 0;
}
