#include <bits/stdc++.h>
using namespace std;
char a[100010], s[100010];
int ar[10];
int main() {
  int n, m, i, j;
  cin >> a >> s;
  n = strlen(a);
  m = strlen(s);
  for (i = 0; i < m; i++) ar[int(s[i] - '0')]++;
  for (i = 0; i < n; i++)
    for (j = 9; j > int(a[i] - '0'); j--)
      if (ar[j]) {
        ar[j]--;
        a[i] = char(int(j + '0'));
      }
  cout << a;
  return 0;
}
