#include <bits/stdc++.h>
using namespace std;
const int maxnnn = 0x3f3f3f3f;
struct node {
  long long x, y;
} ppppos[100050];
bool cmp(long long a, long long b) { return a > b; }
int nex[100100];
int ls, lt;
void get_next(string s) {
  int i = 0;
  int j = -1;
  nex[0] = -1;
  while (i < s.length()) {
    if (j == -1 || s[i] == s[j]) {
      nex[++i] = ++j;
    } else
      j = nex[j];
  }
}
int main() {
  string s, t;
  cin >> s >> t;
  get_next(t);
  ls = 0;
  lt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      lt++;
    else
      ls++;
  }
  int cnt = 0;
  string ans;
  while (lt && ls) {
    if (t[cnt] == '1') {
      if (ls) {
        ls--;
        ans += '1';
      } else
        break;
    } else {
      if (lt) {
        lt--;
        ans += '0';
      } else
        break;
    }
    cnt++;
    if (cnt == t.length()) cnt = nex[cnt];
  }
  while (ls--) ans += '1';
  while (lt--) ans += '0';
  cout << ans << endl;
  return 0;
}
