#include <bits/stdc++.h>
using namespace std;
int fail[500001];
char s[500001], t[500001];
int main() {
  scanf("%s %s", s, t);
  int s1 = count(s, s + strlen(s), '1');
  int s0 = count(s, s + strlen(s), '0');
  int t1 = count(t, t + strlen(t), '1');
  int t0 = count(t, t + strlen(t), '0');
  if (s1 < t1 || s0 < t0) {
    cout << s;
    return 0;
  }
  int p = 0;
  int sl = strlen(s);
  int tl = strlen(t);
  for (int i = 1; i < sl; i++) {
    while (p > 0 && t[p] != t[i]) p = fail[p];
    if (t[p] == t[i]) p++;
    fail[i + 1] = p;
  }
  p = 0;
  for (int i = 0; i < sl; i++) {
    if (t[p] == '0' and s0 > 0) {
      s0--;
      cout << 0;
      p++;
    } else if (t[p] == '1' and s1 > 0) {
      s1--;
      cout << 1;
      p++;
    } else if (s0 > 0) {
      s0--;
      cout << 0;
    } else if (s1 > 0) {
      s1--;
      cout << 1;
    }
    if (p == tl) p = fail[tl];
  }
  return 0;
}
