#include <bits/stdc++.h>
using namespace std;
int n, t[2], m, ans[500005], fail[500005];
char s[500005];
int main() {
  scanf(" %s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) t[s[i] == '1']++;
  scanf("%s", s + 1);
  m = strlen(s + 1);
  int j = 0;
  fail[1] = 0;
  for (int i = 2; i <= m; i++) {
    while (s[j + 1] != s[i] && j) j = fail[j];
    if (s[j + 1] == s[i]) j++;
    fail[i] = j;
  }
  int tp = m - fail[m];
  for (int i = 0, j = 1; i < n; i++, j++) {
    if (j > tp) j = 1;
    if (!t[s[j] == '1'])
      t[!(s[j] == '1')]--, ans[i] = !(s[j] == '1');
    else
      t[s[j] == '1']--, ans[i] = (s[j] == '1');
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  return 0;
}
