#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(vector<T> s) {
  for (T i : s) cout << i << " ";
  cout << endl;
}
void prefix_function(string &s, vector<int> &p) {
  int n = s.size();
  for (int i = 0; i < n; i++) {
    int c = i - 1;
    while (c >= 0) {
      if (s[p[c]] == s[i]) {
        p[i] = p[c] + 1;
        break;
      }
      c = p[c] - 1;
    }
    if (c == -1) p[i] = 0;
  }
}
int getPer(string &s) {
  vector<int> p(s.size());
  prefix_function(s, p);
  return s.size() - p[s.size() - 1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  getline(cin, s);
  getline(cin, t);
  int p = getPer(t);
  int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i < p; i++) {
    if (t[i] == '0')
      cnt0++;
    else
      cnt1++;
  }
  int c0 = 0, c1 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      c0++;
    else
      c1++;
  }
  int cur = 0;
  while (c0 > 0 || c1 > 0) {
    if (c0 == 0) {
      cout << 1;
      c1--;
      continue;
    }
    if (c1 == 0) {
      cout << 0;
      c0--;
      continue;
    }
    if (t[cur++] == '0') {
      cout << 0;
      c0--;
    } else {
      cout << 1;
      c1--;
    }
    if (cur == p) cur = 0;
  }
  cout << endl;
  return 0;
}
