#include <iostream>

using namespace std;

int main()
{
     int a,b,c,d,e,f,g,h,v,n;
cout<<"Unesite dva broja koje Danica zeli da sudari: ";
    cin>>a>>b;
 v=a/1000;
 n=b/1000;
c=(a-(v*1000))/100;
d=(b-(n*1000))/100;
e=(a-(v*1000)-(c*100))/10;
f=(b-(n*1000)-(d*100))/10;
g=a-v*1000-c*100-e*10;
h=b-n*1000-d*100-f*10;
cout<<"To je broj ";
 if(a>999||b>999){
    if(v==n){
        cout<<v<<n;
    }
    else if(v>n){
        cout<<v;
    }
    else
    cout<<n;
    if(c==d){
        cout<<c<<d;
    }
    else if(c>d){
        cout<<c;
    }
    else
    cout<<d;
    if(e==f){
        cout<<e<<f;
    }
     if(e>f){
        cout<<e;
    }
    else
    cout<<f;
    if(g==h){
        cout<<g<<h;
    }
    else if(g>h){
        cout<<g;
    }
    else
    cout<<h;
}
else if(a>99||b>99){
    if(c==d){
        cout<<c<<c;
    }
    else if(c>d){
        cout<<c;
    }
    else
    cout<<d;
    if(e==f){
        cout<<e<<f;
    }
     else if(e>f){
        cout<<e;
    }
    else
    cout<<f;
    if(g==h){
        cout<<g<<h;
    }
    else if(g>h){
        cout<<g;
    }
    else
    cout<<h;
}
else if(a>9||b>9){

    if(e==f){
        cout<<e<<f;
    }
    if(e>f){
        cout<<e;
    }
    else
    cout<<f;
    if(g==h){
        cout<<g<<h;
    }
    else if(g>h){
        cout<<g;
    }
    else
    cout<<h;
}
else
if(g==h){
        cout<<g<<h;
    }
    else if(g>h){
        cout<<g;
    }
    else
    cout<<h;
    return 0;
}