#include using namespace std; using ll = long long; using P = pair; using T = tuple; #define al(a) a.begin(), a.end() #define ral(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define db(a, b) cout << #a << ": " << a << " " << #b << ": " << b << endl; int main() { string s; cin >> s; string ans = s; int n = sz(s); // rep(i, n) rep(j, i) { // swap(s[i], s[j]); // ans = max(ans, s); // swap(s[i], s[j]); // } vector ls(n + 1, -1); P mx(-1, -1); drep(i, n) { auto [val, id] = mx; ls[i] = id; int c = s[i] - '0'; mx = max(mx, P(c, i)); } rep(i, n - 1) { // db(i, ls[i]); swap(s[i], s[ls[i]]); ans = max(ans, s); swap(s[i], s[ls[i]]); } cout << ans << endl; return 0; }