#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

using namespace std;

int main() {
int X,Y,a,b,c,d,a1,b1,c1,d1;
cin >> X >> Y;
a = X / 1000;         
b = (X%1000)/100;  
 d =  X % 10;
 c = (X%100)/10;
 a1 = Y / 1000;          
 b1 = (Y % 1000)/100;  
 d1 =  Y % 10;
 c1 = (Y % 100)/10;
if(a>a1) swap(a,a1);
if(b>b1) swap(b,b1);
if(c>c1) swap(c,c1);
if(d>d1) swap(d,d1);
cout << a1 << b1 << c1 << d1 << endl;


    return 0;
}