#include #include #include using namespace std; int main() { int N; cin >> N; string Ns = to_string(N); for (int i = 0; i < (int)Ns.size(); ++i) { int max = Ns[i]; int idx = i; for (int j = (int)Ns.size() - 1; j >= i + 1; ++j) { if (max < Ns[j]) { max = Ns[j]; idx = j; } } if (idx != i) { swap(Ns[i], Ns[idx]); break; } } cout << Ns << endl; }