#include <bits/stdc++.h>
using namespace std;
int main() {
  int digits[10];
  memset(digits, 0, sizeof(digits));
  string num;
  cin >> num;
  string dig;
  cin >> dig;
  for (int i = 0; i < dig.length(); i++) {
    digits[dig[i] - '0']++;
  }
  int idx = 0;
  while (idx < num.length()) {
    bool flag = false;
    int cur = num[idx] - '0';
    for (int j = 9; j > cur; j--) {
      if (digits[j] > 0) {
        cout << j;
        digits[j]--;
        flag = true;
        break;
      }
    }
    if (!flag) {
      cout << cur;
    }
    idx++;
  }
  return 0;
}
