#include <bits/stdc++.h>
using namespace std;
bool char_is_greater(char c1, char c2) { return (c1 >= c2); }
int main() {
  string a, s;
  cin >> a >> s;
  list<char> lst;
  list<char>::iterator it;
  int sl = s.length(), al = a.length();
  for (int i = 0; i < sl; i++) lst.push_back(s[i]);
  lst.sort(char_is_greater);
  int act = 0;
  string answer = a;
  it = lst.begin();
  while (it != lst.end() && act < al) {
    if (*it > a[act]) {
      answer[act] = *it;
      it++;
    }
    act++;
  }
  cout << answer << endl;
  return 0;
}
