#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long maxi, minn;
  maxi = max(a, b);
  minn = min(a, b);
  while (true) {
    if (maxi % minn == 0) return minn;
    maxi = (maxi % minn);
    if (maxi < minn) swap(maxi, minn);
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  string b, a, k;
  int n, v, m, x = 0;
  cin >> a >> b;
  n = a.length();
  m = b.length();
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < m; i++) {
    v = 0;
    for (int j = x; j <= n; j++) {
      if (b[i] > a[j]) {
        v = 1;
        a[j] = b[i];
        x = i + 1;
        break;
      }
    }
    if (v == 0) break;
  }
  cout << a << endl;
  return 0;
}
