#include #include using namespace std; bool cmp(string s,string t){//return s>t if(s.size() == t.size()){ for(int i = 0; s.size() > i; i++){ if(s[i] > t[i]){ return true; }else if(s[i] < t[i]){ return false; } } return false; } return s.size() > t.size(); } int main(){ string s;cin>>s; string ss = s; sort(ss.begin(),ss.end()); string mx = s; do{ //sとssのdiffを調べる int nw = 0; for(int i = 0; ss.size() > i; i++){ if(ss[i] != s[i])nw++; } if(2 >= nw){ if(cmp(ss,mx)){ mx = ss; } } }while(next_permutation(ss.begin(),ss.end())); cout << mx << endl; }