#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && (c != '-')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int N = 5e5 + 10;
int n, m, cnt[2], fail[N];
char s[N], t[N];
int main() {
  scanf("%s%s", s + 1, t + 1);
  n = strlen(s + 1), m = strlen(t + 1);
  for (register int i = (1); i <= (n); i++) cnt[s[i] - '0']++;
  fail[1] = 0;
  int j = 0;
  for (register int i = (2); i <= (m); i++) {
    while (j && t[i] != t[j + 1]) j = fail[j];
    if (t[i] == t[j + 1]) ++j;
    fail[i] = j;
  }
  int now = 1;
  for (register int i = (1); i <= (n); i++) {
    if (cnt[t[now] - '0']) {
      printf("%c", t[now]), --cnt[t[now] - '0'];
      if (now < m)
        ++now;
      else if (fail[m] == 0)
        now = 1;
      else
        now = fail[m] + 1;
    } else
      printf("%d", (t[now] - '0') ^ 1);
  }
}
