#include <bits/stdc++.h>
using namespace std;
int const maxn = 500010;
int kmpNext[maxn];
void preKMP(string x, int m, int kmpNext[]) {
  int i, j;
  j = kmpNext[0] = -1;
  i = 0;
  while (i < m) {
    while (-1 != j && x[i] != x[j]) j = kmpNext[j];
    if (x[++i] == x[++j])
      kmpNext[i] = kmpNext[j];
    else
      kmpNext[i] = j;
  }
}
int main() {
  string s, t;
  cin >> s;
  int len = s.length();
  int o = 0, l = 0;
  for (int i = 0; i < len; ++i) {
    if (s[i] == '0')
      o++;
    else if (s[i] == '1')
      l++;
  }
  cin >> t;
  int len1 = t.length();
  preKMP(t, len1, kmpNext);
  for (int j, i = 0; o && l;) {
    cout << t[i];
    if (t[i] == '1')
      l--;
    else if (t[i] == '0')
      o--;
    i++;
    if (i == len1) i = kmpNext[i];
  }
  while (o) cout << "0", o--;
  while (l--) cout << "1";
  return 0;
}
