#include <bits/stdc++.h>
const int MN = 1e6 + 7;
int next[MN];
char s[MN], t[MN];
char stack[MN];
int top;
void count01(int &rest_0, int &rest_1) {
  for (char *p = s; *p; ++p)
    if (*p == '0')
      ++rest_0;
    else
      ++rest_1;
  for (char *p = t; *p; ++p)
    if (*p == '0')
      --rest_0;
    else
      --rest_1;
}
int get_next(const char *s, int *next) {
  int i = 0, j = -1, len = strlen(s);
  next[0] = -1;
  while (i < len) {
    if (j == -1 || s[i] == s[j])
      next[++i] = ++j;
    else
      j = next[j];
  }
  return len;
}
int main() {
  scanf("%s %s", s, t);
  int rest_0 = 0, rest_1 = 0;
  count01(rest_0, rest_1);
  if (rest_0 < 0 || rest_1 < 0) return printf(s), 0;
  for (char *p = t; *p; ++p) stack[top++] = *p;
  int len = get_next(t, next);
  char *begin = t + next[len];
  bool ok = true;
  while (ok) {
    for (char *p = begin; *p; stack[top++] = *p++) {
      ok = false;
      if (*p == '0' && rest_0)
        --rest_0, ok = true;
      else if (*p == '1' && rest_1)
        --rest_1, ok = true;
      if (!ok) break;
    }
  }
  printf(stack);
  while (rest_0--) putchar('0');
  while (rest_1--) putchar('1');
  return 0;
}
