#include <bits/stdc++.h>
using namespace std;
char a[100100], b[100100];
int cnt[15];
int main() {
  scanf("%s%s", &a, &b);
  int m = strlen(b);
  int n = strlen(a);
  for (int i = (0); i < (m); ++i) cnt[b[i] - '0']++;
  int cur = 9;
  for (int i = (0); i < (n); ++i) {
    while ((cur >= 0) && (cnt[cur] == 0)) cur--;
    if (cur < 0) break;
    if (cur > a[i] - '0') {
      cnt[cur]--;
      a[i] = cur + '0';
    }
  }
  printf("%s\n", a);
  return 0;
}
