#include <bits/stdc++.h>
using namespace std;
ifstream fin(".in");
string s1, s2;
int z, u, n, m, k, o, p, phi[500010];
int main() {
  ios::sync_with_stdio(false);
  cin >> s1 >> s2;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] == '0')
      z++;
    else
      u++;
  }
  int k = -1;
  phi[0] = -1;
  for (int i = 1; i < s2.size(); i++) {
    while (k != -1 && s2[k + 1] != s2[i]) k = phi[k];
    if (s2[k + 1] == s2[i]) k++;
    phi[i] = k;
  }
  k = -1;
  for (int i = 0; i < s1.size(); i++) {
    if (s2[k + 1] == '0') {
      if (z)
        z--, cout << 0;
      else
        cout << 1;
    } else {
      if (u)
        u--, cout << 1;
      else
        cout << 0;
    }
    k++;
    if (k == s2.size() - 1) k = phi[k];
  }
  return 0;
}
