#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int l;
  vector<int> v;
  cin >> s1 >> s2;
  for (int i = 0; i < s2.length(); i++) {
    if ((s2[i] - '0') > 0) v.push_back(s2[i] - '0');
  }
  sort(v.begin(), v.end());
  int k = v.size() - 1;
  for (int i = 0; i < s1.length(); i++) {
    for (int j = k; j >= 0; j--) {
      if ((s1[i] - '0') < v[j]) {
        k--;
        s1[i] = char(v[j] + '0');
      }
      break;
    }
  }
  cout << s1 << endl;
  return 0;
}
