#include <iostream>
using namespace std;
int main()
{
string s;
cin >> s;
string maxS = s;
int start = s.size() - 1;
bool found = false;
for(int i = 0; i < s.size() and !found; i++){
for(int j = i; j < s.size(); j++){
if(s[j] > s[i]){
start = i;
found = true;
break;
}
}
}
for(int j = start + 1; j < s.size(); j++){
if(s[j] >= s[start]) {
string curMax = s;
for (int k = j; k < s.size(); k++) {
curMax.insert(start + k - j, 1, s[k]);
curMax.erase(k + 1, 1);
maxS = max(curMax, maxS);
}
}
}
cout << maxS;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewogICAgc3RyaW5nIHM7CiAgICBjaW4gPj4gczsKICAgIHN0cmluZyBtYXhTID0gczsKICAgIGludCBzdGFydCA9IHMuc2l6ZSgpIC0gMTsKICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBzLnNpemUoKSBhbmQgIWZvdW5kOyBpKyspewogICAgICAgIGZvcihpbnQgaiA9IGk7IGogPCBzLnNpemUoKTsgaisrKXsKICAgICAgICAgICAgaWYoc1tqXSA+IHNbaV0pewogICAgICAgICAgICAgICAgc3RhcnQgPSBpOwogICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBmb3IoaW50IGogPSBzdGFydCArIDE7IGogPCBzLnNpemUoKTsgaisrKXsKICAgICAgICBpZihzW2pdID49IHNbc3RhcnRdKSB7CiAgICAgICAgICAgIHN0cmluZyBjdXJNYXggPSBzOwogICAgICAgICAgICBmb3IgKGludCBrID0gajsgayA8IHMuc2l6ZSgpOyBrKyspIHsKICAgICAgICAgICAgICAgIGN1ck1heC5pbnNlcnQoc3RhcnQgKyBrIC0gaiwgMSwgc1trXSk7CiAgICAgICAgICAgICAgICBjdXJNYXguZXJhc2UoayArIDEsIDEpOwogICAgICAgICAgICAgICAgbWF4UyA9IG1heChjdXJNYXgsIG1heFMpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBtYXhTOwogICAgcmV0dXJuIDA7Cn0=