#include <bits/stdc++.h>
using namespace std;
 

string maxValue(string a, string b)
{
    
    sort(b.begin(), b.end());
    int n = a.length();
    int m = b.length();
 
    
    int j = m - 1;
    for (int i = 0; i < n; i++) {
 
        
        if (j < 0)
            break;
 
        if (b[j] > a[i]) {
            a[i] = b[j];
 
            
            j--;
        }
    }
 
    
    return a;
}
 

int main()
{
    string b = "";
    string a = "";

	cin >> b;
	cin >> a;
	
	
	
 
    cout << maxValue(a, b);
 
    return 0;
}