#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int n, m, i, j = 0;
  cin >> s >> t;
  n = s.size();
  m = t.size();
  sort(t.rbegin(), t.rend());
  for (i = 0; i < m; i++) {
    for (; j < n;) {
      if (t[i] <= s[j]) {
        j++;
      } else if (t[i] != '0' && t[i] > s[j]) {
        s[j] = t[i];
        break;
      }
    }
  }
  cout << s << endl;
}
