#include <iostream>

using namespace std; 

int main () {
    
    ios_base::sync_with_stdio(false); 
    cin.tie();
    cout.tie(); 
    
    long long n, m; 
    long long ma = m; 
    
    cin>>n;
    cin>>m; 
    
    long long r = 0;
    
    while(n > 0) {
        
        if(m == 0) {
            
            ma = n;
            break; 
            
        } 
        
        long long n_10 = n%10; 
        long long m_10 = m%10; 
        
        r = n_10 > m_10 ? (r * 10 + n_10) : (r * 10 + m_10); 
        
        if(n_10 == m_10) { r =  r * 10 + n_10; }
        
        n /= 10;
        m /= 10; 
        
        ma = m; 
        
    }
    
    while(r > 0) {
        
        ma = ma * 10 + r%10; 
        
        r /= 10; 
        
    }
    
    cout<<ma; 
    
    return 0; 
    
}