#include <bits/stdc++.h>
using namespace std;
char str[500005], ctr[500005];
char gtr[500005];
int next2[500005];
void getnext() {
  int i = 0, j = -1;
  next2[0] = -1;
  int m = strlen(ctr);
  while (i < m) {
    if (j == -1 || ctr[i] == ctr[j]) {
      next2[++i] = ++j;
    } else {
      j = next2[j];
    }
  }
}
int main() {
  scanf("%s", &str);
  scanf("%s", &ctr);
  int alen = strlen(str);
  int blen = strlen(ctr);
  if (alen >= blen) {
    int sum = 0;
    for (int i = 0; i < alen; i++)
      if (str[i] == '1') sum++;
    int ans = alen - sum;
    int q = 0, p = 0;
    getnext();
    for (int i = 0, j = 0; j < alen; i++, j++) {
      if (i == blen) i = next2[blen];
      if (q < sum && ctr[i] == '1') {
        gtr[j] = '1';
        q++;
      } else if (p < ans) {
        gtr[j] = '0';
        p++;
      } else {
        gtr[j] = '1';
        q++;
      }
    }
    gtr[alen] = '\0';
    printf("%s\n", gtr);
  } else
    printf("%s\n", str);
  return 0;
}
