import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
// String str = “abc”;
ArrayList storVal = permution1(str);
display(storVal,str);
}
public static ArrayList<String> permution1(String str){
if(str.length()==0)
{
ArrayList<String> retval = new ArrayList<String>();
retval.add("");
return retval;
}
char cc = str.charAt(0);
String substr = str.substring(1);
ArrayList<String> myRes = new ArrayList<String>();
ArrayList<String> retRes = permution1(substr);
for(String s:retRes){
for(int i=0;i<=s.length();i++){
myRes.add( s.substring(0,i)+cc+s.substring(i));
}
}
return myRes;
}
public static void display(ArrayList storVal,String str){
//String max = str;
int len = storVal.size();
for(int i=0;i<len;i++){
for(int j=0;j<len;j++){
if(storVal.get(j).compareTo(storVal.get(i))>0 ){
String temp = storVal.get(j);
storVal.set(j,storVal.get(i));
storVal.set(i,temp);
}
}
}
int counter = 0;
for(String s : storVal){
if(s.equals(str)){
counter = counter+1;
}
else if(counter == 1){
System.out.println(s);
}
}
}
}