#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, s;
  cin >> a >> s;
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int k = 0;
  for (int i = 0; i < a.size() && i < s.size(); i++) {
    bool found = false;
    for (int j = k; j < a.size(); j++) {
      if (s[i] > a[j]) {
        a[j] = s[i];
        found = true;
        k = j;
        break;
      }
    }
    if (!found) break;
  }
  cout << a << endl;
}
