#include <bits/stdc++.h>
using namespace std;
char a[100020], b[100020];
int main() {
  scanf("%s", a);
  scanf("%s", b);
  int n(strlen(a)), m(strlen(b));
  sort(b, b + m);
  int j = m - 1;
  ;
  for (int i = 0; i <= n - 1; ++i)
    if (b[j] > a[i]) {
      a[i] = b[j];
      --j;
      if (j < 0) break;
    }
  for (int i = 0; i <= n - 1; ++i) printf("%d", a[i] - 48);
  cout << endl;
}
