#include <bits/stdc++.h>
using namespace std;
string s, t;
int lps[500000];
int rem[2], need[2];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s >> t;
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < t.length()) {
    if (t[i] == t[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0)
        len = lps[len - 1];
      else {
        lps[i] = 0;
        i++;
      }
    }
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      rem[0]++;
    else
      rem[1]++;
  }
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '0')
      need[0]++;
    else
      need[1]++;
  }
  int l = lps[t.length() - 1];
  if (need[0] > rem[0] || need[1] > rem[1]) {
    cout << s << endl;
    return 0;
  }
  for (int i = 0; i < t.length(); i++) cout << t[i];
  rem[0] -= need[0];
  rem[1] -= need[1];
  for (int i = 0; i < l; i++) {
    if (t[i] == '0')
      need[0]--;
    else
      need[1]--;
  }
  while (rem[0] >= need[0] && rem[1] >= need[1]) {
    for (int i = l; i < t.length(); i++) cout << t[i];
    rem[0] -= need[0];
    rem[1] -= need[1];
  }
  for (int i = 0; i < rem[0]; i++) cout << "0";
  for (int i = 0; i < rem[1]; i++) cout << "1";
  cout << endl;
  return 0;
}
