/*
TASK: names
LANG: C++
*/

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int i,j,n;
string a;
void solve();
void init(){
	//freopen("inp3.txt","rt",stdin);
    //freopen("outp3.txt","wt",stdout);

    while(cin>>a){
        n=a.size();
        solve();
    }
}
string save,cur;
string s1,s2,s3;
void solve(){

int t1,t2,t3;
	save=a;
	for(i=0;i<n;i++)
    	for(j=1;j<n-i;j++){
           
           	s1=a.substr(0,i);
            s2=a.substr(i,j);
            //if(i+j<=n-1)
            s3=a.substr(i+j,n-i-j);

            //cout<<s1<<" "<<s2<<" "<<s3<<endl;
            t1=(s1<s2)?1:0;
            t2=(s2<s3)?1:0;
            t3=(s1<s3)?1:0;
            if(t1==1){
            	if(t2==1){//123
                }
                else if(t3){//132
                	cur=s1+s3+s2;
                    if(cur<save)save=cur;
                }
                else {//312
                	cur=s3+s1+s2;
                    if(cur<save)save=cur;
                }
            }
            else {
            	if(t2){
                	if(t3){//213
                    	cur=s2+s1+s3;
                        if(cur<save)save=cur;
                    }
                    else {//231
                    	cur=s2+s3+s1;
                        if(cur<save)save=cur;
                    }
                }
                //else {//321 otpada
                //}
            }
        }
 	cout<<save<<endl;
}

int main(){
    init();
    return 0;
}

