#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  vector<int> arr(t.length());
  arr[0] = 0;
  int next = 0;
  int j = 1;
  while (j < t.length()) {
    if (t[j] == t[next]) {
      next++;
      arr[j] = next;
      j++;
    } else {
      if (next == 0)
        j++;
      else
        next = arr[next - 1];
    }
  }
  int index = arr[t.length() - 1];
  int ones = 0;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == '1') ones++;
  int ones2 = 0;
  for (j = 0; j < t.length(); j++)
    if (t[j] == '1') ones2++;
  int ones3 = 0;
  for (j = index; j < t.length(); j++)
    if (t[j] == '1') ones3++;
  int zeros = s.length() - ones;
  int zeros2 = t.length() - ones2;
  int zeros3 = (t.length() - index) - ones3;
  if (zeros2 > zeros || ones2 > ones) {
    cout << s;
    return 0;
  } else {
    cout << t;
    zeros -= zeros2;
    ones -= ones2;
    while (zeros - zeros3 >= 0 && ones - ones3 >= 0) {
      cout << t.substr(index, t.length());
      zeros -= zeros3;
      ones -= ones3;
    }
    while (zeros != 0) {
      cout << "0";
      zeros--;
    }
    while (ones != 0) {
      cout << "1";
      ones--;
    }
  }
}
