#include <bits/stdc++.h>
using namespace std;
string a, b;
int f[2];
int getLps(string x) {
  vector<int> lps(x.size());
  int i = 1;
  int j = 0;
  while (i < x.size()) {
    if (x[i] == x[j]) {
      lps[i++] = ++j;
    } else {
      if (j != 0) {
        j = lps[j - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
  return lps.back();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  for (int i = 0; i < a.size(); ++i) {
    f[a[i] - '0']++;
  }
  int k = getLps(b);
  int j = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (j == b.size()) {
      j = k;
    }
    if (f[b[j] - '0']) {
      f[b[j] - '0']--;
      cout << b[j];
    } else {
      f[1 - (b[j] - '0')]--;
      cout << 1 - (b[j] - '0');
    }
    j++;
  }
}
