#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int number_set[10] = {0};
  for (char i : s2) number_set[i - '0']++;
  for (int digit = 9; digit >= 1; digit--) {
    int n_digit = number_set[digit];
    for (int j = 0; n_digit && j < s1.length(); j++)
      if (s1[j] - '0' < digit) {
        s1[j] = digit + '0';
        n_digit--;
      }
  }
  cout << s1 << endl;
  return 0;
}
