#include <bits/stdc++.h>
using namespace std;
char a[100009];
char c[100009];
int p[10];
int main() {
  char b;
  string f;
  string s;
  cin >> f;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    int temp = (int)s[i] - (int)'0';
    p[temp]++;
  }
  int last = 9;
  for (int i = 0; i < f.length(); i++) {
    int d = (int)f[i] - (int)'0';
    for (int j = last; j > d; j--) {
      if (p[j] > 0) {
        p[j]--;
        if (p[j] == 0) {
          last--;
        }
        char h = (char)((int)'0' + j);
        f[i] = h;
        break;
      }
    }
  }
  cout << f;
  return 0;
}
