#include <bits/stdc++.h>
using namespace std;
int main() {
  string b, a;
  cin >> b >> a;
  vector<int> coun(9);
  bool p = false;
  int n, m;
  n = b.length();
  m = a.length();
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < m; i++) {
    coun[9 - (a[i] - '0')]++;
  }
  for (int i = 0; i < 9; i++) {
    if (coun[i] != 0) {
      for (int j = 0; j < n; j++) {
        int k = 9 - i;
        if (k > (b[j] - '0')) {
          coun[i]--;
          b[j] = k + '0';
        }
        if (coun[i] == 0) break;
      }
    }
  }
  cout << b << endl;
}
