#include <bits/stdc++.h>
using namespace std;
vector<int> stoiv(string);
int main() {
  string a, s;
  cin >> a >> s;
  vector<int> v_a = stoiv(a);
  vector<int> v_s = stoiv(s);
  sort(v_s.begin(), v_s.end());
  stack<int> S;
  int a_len = a.length();
  int s_len = s.length();
  for (int i = 0; i < s_len; i++) S.push(v_s[i]);
  for (int i = 0; i < a_len; i++) {
    if (S.empty()) break;
    int cur = S.top();
    if (cur > v_a[i]) {
      S.pop();
      a[i] = (char)(cur + 48);
    }
  }
  cout << a << endl;
  return 0;
}
vector<int> stoiv(string str) {
  vector<int> vec(str.length());
  int len = str.length();
  for (int i = 0; i < len; i++) {
    vec[i] = (int)str[i] - 48;
  }
  return vec;
}
