#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e5 + 7, MOD = 81409, inf = 1e9, N = 1e4 + 7;
long long n, k = 6, cnt[10], help, pa, push_back;
string a, b;
int main() {
  cin >> a >> b;
  for (unsigned long long int i = 0; i < b.size(); i++) cnt[b[i] - '0']++;
  for (long long i = 0; i <= 9; i++) cerr << cnt[i] << " ";
  cerr << "\n";
  for (unsigned long long int i = 0; i < a.size(); i++) {
    help = a[i] - '0';
    cerr << help << " ";
    for (int j = 9; j > help; j--) {
      if (cnt[j]) {
        cnt[j]--;
        a[i] = j + '0';
        break;
      }
    }
    cerr << "\n";
  }
  return cout << a << "\n", 0;
}
