#include "bits/stdc++.h" using namespace std; int main() { string S, T; cin >> S; T = S; sort(T.begin(), T.end(), greater()); for (int i = 0; i < S.size(); i++) { if (S[i] != T[i]) { for (int j = S.size() - 1; j > i; j--) { if (S[j] == T[i]) { swap(S[i], S[j]); cout << S << endl; return 0; } } } } cout << S << endl; }