#include <bits/stdc++.h>
#pragma comment(linker, "/stack:67108864")
using namespace std;
template <class T>
inline T abs(T a) {
  return (a) > 0 ? (a) : -(a);
}
template <class T>
inline T sqr(T a) {
  return (a) * (a);
}
const long double PI = 3.1415926535897932, EPS = 1E-9;
const int INF = 1000 * 1000 * 1000, NMAX = 1000005;
int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  vector<int> v;
  for (register int i = 0; i < int((t).size()); ++i) {
    v.push_back(int(t[i] - '0'));
  }
  sort((v).begin(), (v).end(), greater<int>());
  int pos = 0;
  for (register int i = 0; i < int((s).size()); ++i) {
    if (pos >= int(v.size())) break;
    if (int(s[i] - '0') < v[pos]) {
      s[i] = char(v[pos] + '0');
      pos++;
    }
  }
  cout << s;
  return 0;
}
