#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long M = 1e9 + 7;
template <typename T>
void print(vector<T>& v) {
  cout << "[";
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i];
    if (i != v.size() - 1) cout << ", ";
  }
  cout << "]\n";
}
template <typename T>
void print(set<T>& v) {
  cout << "[";
  for (auto it : v) {
    cout << it;
    if (it != *v.rbegin()) cout << ", ";
  }
  cout << "]\n";
}
template <typename T, typename S>
void print(map<T, S>& v) {
  for (auto it : v) cout << it.first << " : " << it.second << "\n";
}
template <typename T, typename S>
void print(pair<T, S>& v) {
  cout << "( " << v.first << ", " << v.second << " )" << '\n';
}
template <typename T>
void print(T x) {
  cout << x << '\n';
}
vector<int> prefix_function(string& s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; i++) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) j++;
    pi[i] = j;
  }
  return pi;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  vector<int> p = prefix_function(t);
  int n = t.length();
  int preflen = p[n - 1];
  string app = t.substr(preflen, t.length() - preflen);
  vector<int> supply(2), tr(2), ar(2);
  for (int i = 0; i < s.length(); i++) {
    supply[s[i] - '0']++;
  }
  for (int i = 0; i < t.length(); i++) tr[t[i] - '0']++;
  for (int i = 0; i < app.length(); i++) ar[app[i] - '0']++;
  if (supply[0] < tr[0] || supply[1] < tr[1]) {
    cout << s << '\n';
    return 0;
  }
  cout << t;
  supply[0] -= tr[0];
  supply[1] -= tr[1];
  while (supply[0] >= ar[0] && supply[1] >= ar[1]) {
    cout << app;
    supply[0] -= ar[0];
    supply[1] -= ar[1];
  }
  for (int i = 0; i < supply[0]; i++) cout << '0';
  for (int i = 0; i < supply[1]; i++) cout << '1';
  cout << '\n';
}
