#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int coun[10];
  for (int i = 0; i < 10; i++) coun[i] = 0;
  for (int i = 0; i < b.size(); i++) coun[b[i] - '0']++;
  for (int i = 0; i < a.size(); i++) {
    for (int j = 9; j > -1; j--) {
      if (coun[j] > 0 && j > a[i] - '0') {
        coun[j]--;
        a[i] = j + '0';
        break;
      }
    }
  }
  cout << a;
}
