#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int nxt[maxn];
char s[maxn], t[maxn], tmp[maxn];
void makeNext() {
  int q, k, len = strlen(t);
  nxt[0] = 0;
  for (q = 1, k = 0; q < len; q++) {
    while (k > 0 && t[q] != t[k]) k = nxt[k - 1];
    if (t[q] == t[k]) k++;
    nxt[q] = k;
  }
}
int main() {
  int a = 0, b = 0, suma = 0, sumb = 0;
  scanf("%s%s", s, t);
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == '1')
      suma++;
    else
      sumb++;
  }
  for (int i = 0; i < strlen(t); i++) {
    if (t[i] == '1')
      suma--;
    else
      sumb--;
  }
  if (suma < 0 || sumb < 0)
    printf("%s\n", s);
  else {
    makeNext();
    int tmpa = 0, tmpb = 0, q = 0x3f3f3f3f, cnt = 0;
    int p = nxt[strlen(t) - 1];
    for (int i = p; i < strlen(t); i++) {
      if (t[i] == '1')
        tmpa++;
      else
        tmpb++;
      tmp[cnt++] = t[i];
    }
    if (tmpa) q = min(q, suma / tmpa);
    if (tmpb) q = min(q, sumb / tmpb);
    printf("%s", t);
    for (int i = 0; i < q; i++) printf("%s", tmp);
    for (int i = 0; i < suma - q * tmpa; i++) printf("1");
    for (int i = 0; i < sumb - q * tmpb; i++) printf("0");
    printf("\n");
  }
}
