#include <bits/stdc++.h>
using namespace std;
int main() {
  string second, t;
  cin >> second >> t;
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 0; i < second.size(); i++) {
    if (second[i] == '0') {
      a++;
    } else {
      b++;
    }
  }
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == '0') {
      c++;
    } else {
      d++;
    }
  }
  if (t.size() > second.size()) {
    cout << second << endl;
    return 0;
  }
  if (t.size() == second.size()) {
    if (a == c && b == d) {
      cout << t << endl;
    } else {
      cout << second << endl;
    }
    return 0;
  }
  if (c > a || d > b) {
    cout << second << endl;
    return 0;
  }
  int store = 0;
  for (int i = 1; i < t.size(); i++) {
    if (t.substr(i, t.size() - i) == t.substr(0, t.size() - i)) {
      store = t.size() - i;
      break;
    }
  }
  string rep = t.substr(store, t.size() - store);
  int rep0 = 0, rep1 = 0;
  for (int i = 0; i < rep.size(); i++) {
    if (rep[i] == '0') {
      rep0++;
    } else {
      rep1++;
    }
  }
  string ans = t;
  a -= c;
  b -= d;
  while (a - rep0 >= 0 && b - rep1 >= 0) {
    ans += rep;
    a -= rep0;
    b -= rep1;
  }
  for (int i = 0; i < a; i++) {
    ans += '0';
  }
  for (int i = 0; i < b; i++) {
    ans += '1';
  }
  cout << ans << endl;
  return 0;
}
