#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, m, nxt[N];
char s[N], t[N];
void getNext() {
  nxt[0] = -1;
  int j = -1;
  for (register int i = 1; i <= m; ++i) {
    while (j >= 0 && t[j + 1] != t[i]) j = nxt[j];
    nxt[i] = ++j;
  }
}
int main() {
  scanf("%s%s", s + 1, t + 1);
  n = strlen(s + 1), m = strlen(t + 1);
  getNext();
  int s0 = 0, s1 = 0;
  for (register int i = 1; i <= n; ++i) {
    if (s[i] == '0')
      s0++;
    else
      s1++;
  }
  int j = 0;
  for (register int i = 1; i <= n; ++i) {
    if (j == m) j = nxt[j];
    ++j;
    if (t[j] == '0' && !s0) break;
    if (t[j] == '1' && !s1) break;
    s0 -= (t[j] == '0');
    s1 -= (t[j] == '1');
    putchar(t[j]);
  }
  for (register int i = 1; i <= s0; ++i) putchar('0');
  for (register int i = 1; i <= s1; ++i) putchar('1');
  return 0;
}
