#include <bits/stdc++.h>
using namespace std;
char s[(500000 + 10)], t[(500000 + 10)];
int f[(500000 + 10)];
void getf(char* ss, int len) {
  f[0] = -1;
  int fail = -1, pos = 0;
  while (pos < len) {
    while (fail != -1 && ss[pos] != ss[fail]) fail = f[fail];
    f[++pos] = ++fail;
  }
}
int main() {
  scanf("%s%s", s, t);
  int len = strlen(t);
  getf(t, len);
  int n1 = 0, n0 = 0;
  for (int i = 0; s[i]; i++)
    if (s[i] == '0')
      n0++;
    else
      n1++;
  int p = 0;
  while (n1 && n0) {
    if (p == len) {
      p = f[len];
      continue;
    }
    if (t[p] == '0' && n0)
      printf("0"), n0--;
    else if (t[p] == '1' && n1)
      printf("1"), n1--;
    p++;
  }
  while (n1--) printf("1");
  while (n0--) printf("0");
  return 0;
}
