#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  vector<int> z(t.size(), 0);
  for (int i = 1, l = 0, r = 0; i < t.size(); i++) {
    if (i <= r) {
      z[i] = min(r - i + 1, z[i - l]);
    }
    while (i + z[i] < t.size() && t[z[i]] == t[i + z[i]]) {
      z[i]++;
    }
    if (i + z[i] - 1 > r) {
      l = i;
      r = i + z[i] - 1;
    }
  }
  int p = z.size();
  for (int i = 1; i < z.size(); i++) {
    if (z[i] >= z.size() - i) {
      p = i;
      break;
    }
  }
  int a = 0, b = 0;
  for (auto c : s) {
    if (c == '0') {
      a++;
    } else {
      b++;
    }
  }
  string q;
  while (q.size() < s.size()) {
    if (t[q.size() % p] == '0' && a == 0) {
      q.push_back('1');
      b--;
    } else if (t[q.size() % p] == '1' && b == 0) {
      q.push_back('0');
      a--;
    } else if (t[q.size() % p] == '0') {
      q.push_back('0');
      a--;
    } else {
      q.push_back('1');
      b--;
    }
  }
  cout << q;
  return 0;
}
