#include <bits/stdc++.h>
using namespace std;
string s, t;
int cnt[15];
int main() {
  cin >> s >> t;
  for (int i = 0; i < 10; ++i) cnt[i] = 0;
  for (int i = 0; i < t.length(); ++i) ++cnt[t[i] - '0'];
  int j = 9;
  for (int i = 0; j >= 0 && i < s.length(); ++i) {
    while (j >= 0 && cnt[j] == 0) --j;
    if (j >= 0 && s[i] < j + '0') s[i] = j + '0', --cnt[j];
  }
  cout << s << "\n";
  return 0;
}
