#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
const long long Mod = 1000000007;
int nxt[maxn];
string s, t;
int n;
void getnxt() {
  n = t.length();
  int j = 0, k = -1;
  nxt[0] = -1;
  while (j < n) {
    if (k == -1 || t[j] == t[k]) {
      j++;
      k++;
      nxt[j] = k;
    } else
      k = nxt[k];
  }
}
int ss[2], tt[2], gg[2];
string g;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ;
  cin >> s >> t;
  getnxt();
  int m = s.length();
  for (int i = 0; i < m; i++) {
    ss[int(s[i] - '0')]++;
  }
  for (int i = 0; i < n; i++) {
    tt[int(t[i] - '0')]++;
  }
  int st = nxt[n];
  g = "";
  for (int i = st; i < n; i++) {
    gg[int(t[i] - '0')]++;
    g += t[i];
  }
  if (ss[0] < tt[0] || ss[1] < tt[1]) {
    cout << s << endl;
    return 0;
  }
  cout << t;
  for (int i = 0; i <= 1; i++) ss[i] -= tt[i];
  while (ss[0] >= gg[0] && ss[1] >= gg[1]) {
    cout << g;
    for (int i = 0; i <= 1; i++) ss[i] -= gg[i];
  }
  for (int i = 1; i <= ss[0]; i++) cout << 0;
  for (int i = 1; i <= ss[1]; i++) cout << 1;
  cout << endl;
  return 0;
}
