#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int F = 4e5 + 5, M = 4e5 + 6, OO = 0x3f3f3f3f, MOD = 1e9 + 7;
int d[11];
int main() {
  string a, s;
  cin >> a >> s;
  for (int i = 0; i < s.size(); i++) d[s[i] - '0']++;
  for (int i = 0; i < a.size(); i++)
    for (int j = 9; j >= 0; j--)
      if (a[i] - '0' < j && d[j]) {
        a[i] = char(j + '0');
        d[j]--;
      }
  cout << a;
  return 0;
}
