#include <bits/stdc++.h>
using namespace std;
string s, t, k;
int p[500005], c0, c1, f0, f1, a0, a1;
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> s >> t;
  p[0] = -1;
  int j = -1;
  for (int i = 1; i < t.size(); i++) {
    if (t[i] == t[j + 1])
      j++, p[i] = j;
    else {
      while (j != -1 && t[i] != t[j + 1]) j = p[j];
      if (t[i] == t[j + 1]) j++;
      p[i] = j;
    }
  }
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      a0++;
    else
      a1++;
  }
  for (int i = 0; i <= p[t.size() - 1]; i++) {
    if (t[i] == '0')
      f0++;
    else
      f1++;
  }
  for (int i = p[t.size() - 1] + 1; i < t.size(); i++) {
    if (t[i] == '0')
      c0++;
    else
      c1++;
    k += t[i];
  }
  if (a0 >= f0 + c0 && a1 >= f1 + c1) {
    cout << t;
    a0 -= f0 + c0;
    a1 -= f1 + c1;
    while (a0 >= c0 && a1 >= c1) {
      cout << k;
      a0 -= c0;
      a1 -= c1;
    }
  }
  while (a0) cout << '0', a0--;
  while (a1) cout << '1', a1--;
}
