#include <bits/stdc++.h>
using namespace std;
int main() {
  string a = "", s, st;
  cin >> st >> s;
  sort(s.begin(), s.end());
  a = st;
  sort(st.begin(), st.end());
  if (st[0] > s[(int)(s).size() - 1]) {
    cout << a << endl;
    return 0;
  } else {
    int i = (int)(s).size() - 1;
    int j = 0;
    while (j < (int)(a).size()) {
      if (a[j] < s[i]) {
        a[j] = s[i];
        j++;
        i = i - 1;
      } else
        j++;
    }
  }
  cout << a << endl;
  return 0;
}
