#include <bits/stdc++.h>
using namespace std;
void prefix_function(string &s, vector<int> &p) {
  int n = s.length();
  p.resize(n);
  p[0] = 0;
  int j;
  for (int i = 1; i < n; i++) {
    j = p[i - 1];
    while (j && s[i] != s[j]) {
      j = p[j - 1];
    }
    if (s[i] == s[j]) {
      j++;
    }
    p[i] = j;
  }
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string s, t;
  cin >> s >> t;
  vector<int> p;
  prefix_function(t, p);
  int a = 0, b = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      a++;
    else
      b++;
  }
  int i = 0;
  while (a || b) {
    if (t[i] == '0') {
      if (a) {
        cout << 0;
        a--;
      } else {
        cout << 1;
        b--;
      }
    } else {
      if (b) {
        cout << 1;
        b--;
      } else {
        cout << 0;
        a--;
      }
    }
    i++;
    if (i == t.size()) {
      i = p.back();
    }
  }
  return 0;
}
