#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
int Next[N];
void getNext(const string& src) {
  int p, q;
  p = 0, q = -1;
  Next[0] = -1;
  while (p < src.size()) {
    if (q == -1 || src[p] == src[q]) {
      p++;
      q++;
      Next[p] = q;
    } else {
      q = Next[q];
    }
  }
}
int getOneCnt(const string& str) {
  int cnt = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '1') cnt++;
  }
  return cnt;
}
bool generation(string& output_str, int output_len, int one_cnt,
                const string& pattern, int pattern_length) {
  int pointer = -1;
  for (int i = 0; i < output_len; i++) {
    if (one_cnt <= 0)
      output_str[i] = '0';
    else {
      pointer++;
      if (pointer == pattern_length) {
        pointer = Next[pointer];
      }
      output_str[i] = pattern[pointer];
      if (output_str[i] == '1') {
        one_cnt--;
      }
    }
  }
  if (one_cnt > 0) {
    for (int i = output_len - 1; i >= 0; i--) {
      if (output_str[i] == '0') output_str[i] = '1', one_cnt--;
      if (one_cnt == 0) break;
    }
  }
  return true;
}
int main() {
  string input_str, pattern;
  cin >> input_str >> pattern;
  string output_str(input_str);
  getNext(pattern);
  int len = input_str.size(), one_cnt = getOneCnt(input_str);
  generation(output_str, output_str.size(), one_cnt, pattern, pattern.size());
  cout << output_str << endl;
}
