#include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; int main() { string s; cin >> s; int id = 0; while(true) { REP(i,id,s.size()) { if(s[i] == '9') continue; else { id = i; break; } } int idx = id; char c = s[id]; REP(i,id+1,s.size()) { if(c <= s[i]) { c = s[i]; idx = i; } } if(id != idx || id == s.size()-1) { swap(s[id],s[idx]); break; } id++; } cout << s << endl; return 0; }