#include <bits/stdc++.h>
using namespace std;
const int INF = (1LL << 31) - 1;
int main() {
  string n;
  cin >> n;
  string s;
  cin >> s;
  int use = 0;
  int cnt[11] = {0};
  for (int i = 0; i < s.size(); ++i) cnt[s[i] - '0']++;
  for (int i = 0; i < n.size(); ++i) {
    for (int j = 9; j >= 0; --j)
      if (cnt[j] && j > (n[i] - '0')) {
        n[i] = j + '0';
        cnt[j]--;
        break;
      }
  }
  cout << n << endl;
  return 0;
}
