#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  string a, s;
  cin >> a >> s;
  vector<int> v(10, 0);
  for (int i = 0; i < s.size(); i++) v[s[i] - 48]++;
  int j = 9;
  for (int i = 0; i < a.size(); i++) {
    while (v[j] == 0 and j > 0) j--;
    if (j > a[i] - 48) {
      a[i] = j + 48;
      v[j]--;
    }
  }
  cout << a << endl;
  return 0;
}
