#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
static int N, C[2], K[2], kmp[MAXN];
static char S[MAXN];
inline void get_kmp(void) {
  kmp[0] = -1;
  for (int i = 0, j = -1; i < N;) {
    if (j == -1 || S[i] == S[j])
      kmp[++i] = ++j;
    else
      j = kmp[j];
  }
}
int main() {
  scanf("%s", S);
  for (int i = 0; S[i]; i++) C[S[i] - '0']++;
  scanf("%s", S);
  for (int i = 0; S[i]; i++) K[S[i] - '0']++;
  N = strlen(S);
  get_kmp();
  if (C[0] >= K[0] && C[1] >= K[1]) {
    printf("%s", S);
    C[0] -= K[0];
    C[1] -= K[1];
    for (int i = 0; i < kmp[N]; i++) K[S[i] - '0']--;
    while (C[0] >= K[0] && C[1] >= K[1]) {
      for (int i = kmp[N]; i < N; i++) printf("%c", S[i]);
      C[0] -= K[0];
      C[1] -= K[1];
    }
  }
  for (int i = 0; i < C[0]; i++) putchar('0');
  for (int i = 0; i < C[1]; i++) putchar('1');
  puts("");
  return 0;
}
