#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int maxn = 5e5 + 10;
int Next[maxn];
void get_next(string t) {
  int j = -1;
  Next[0] = -1;
  for (int i = 0; i < t.size();) {
    if (j == -1 || t[i] == t[j])
      Next[++i] = ++j;
    else
      j = Next[j];
  }
}
void conunt_it(string s, int &zero, int &one) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      zero++;
    } else
      one++;
  }
}
int main() {
  string s, t;
  cin >> s >> t;
  get_next(t);
  int zero = 0, one = 0;
  conunt_it(s, zero, one);
  int cnt = 0;
  while (zero > 0 && one > 0) {
    if (t[cnt] == '0') {
      if (zero > 0) {
        putchar('0');
        zero--;
      } else {
        break;
      }
    } else {
      if (one > 0) {
        putchar('1');
        one--;
      } else {
        break;
      }
    }
    cnt++;
    if (cnt == t.size()) cnt = Next[cnt];
  }
  while (one--) putchar('1');
  while (zero--) putchar('0');
  cout << endl;
  return 0;
}
