#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string a, s;
  cin >> a >> s;
  int n = (int)a.size();
  int m = (int)s.size();
  int cnt[10] = {0};
  for (int i = 0; i < m; i++) {
    cnt[s[i] - '0']++;
  }
  for (int i = 0; i < n; i++) {
    int x = a[i] - '0';
    for (int j = 9; j >= 0; j--) {
      if (x < j && cnt[j]) {
        a[i] = j + '0';
        cnt[j]--;
        break;
      }
    }
  }
  cout << a << "\n";
}
