#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, s;
  cin >> a;
  cin >> s;
  int num[10] = {0};
  for (int i = 0; i < s.size(); i++) {
    num[s[i] - '0']++;
  }
  for (int i = 0; i < a.size(); i++) {
    bool found = false;
    for (int j = 9; j > (a[i] - '0'); j--) {
      if (num[j] > 0) {
        num[j]--;
        printf("%d", j);
        found = true;
        break;
      }
    }
    if (!found) printf("%c", a[i]);
  }
  return 0;
}
