#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, start;
  string a;
  string s;
  cin >> a >> s;
  sort(s.begin(), s.end());
  n = a.size();
  k = s.size();
  start = k - 1;
  for (i = 0; i < n; i++) {
    if (a[i] < s[start]) {
      a[i] = s[start];
      start--;
      if (start == -1) break;
    }
  }
  for (i = 0; i < n; i++) cout << a[i];
  return 0;
}
