#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  string s = " ";
  sort(b.rbegin(), b.rend());
  if (a.size() > b.size())
    s = b.substr(0, a.size());
  else
    s = b;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '9')
      continue;
    else if ((a[i] + '0') < (s[0] + '0')) {
      a[i] = s[0];
      s.erase(0, 1);
    }
  }
  cout << a << endl;
}
