#include <bits/stdc++.h>
using namespace std;
int lpss(string s) {
  int n = s.length();
  int lps[n];
  lps[0] = 0;
  int len = 0;
  int i = 1;
  while (i < n) {
    if (s[i] == s[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
  int res = lps[n - 1];
  return res;
}
int main() {
  string s, t;
  cin >> s >> t;
  int z = 0, o = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1')
      ++o;
    else
      ++z;
  }
  int z1 = 0, o1 = 0;
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '1')
      ++o1;
    else
      ++z1;
  }
  if (z >= z1 and o >= o1) {
    cout << t;
    z -= z1;
    o -= o1;
  } else {
    cout << s;
    return 0;
  }
  int x = lpss(t);
  string ans = "";
  int z2 = 0, o2 = 0;
  for (int i = t.length() - 1; i >= x; i--) {
    if (t[i] == '1')
      ++o2;
    else
      ++z2;
    ans.push_back(t[i]);
  }
  reverse(ans.begin(), ans.end());
  while (z >= z2 and o >= o2) {
    o -= o2;
    z -= z2;
    cout << ans;
  }
  for (int i = 0; i < z; i++) cout << 0;
  for (int i = 0; i < o; i++) cout << 1;
}
