#include using namespace std; int main() { string N; cin >> N; int Max_number = 0; int N_N = N.size(); for (int i = 0; i < N_N; i++) { Max_number = max(Max_number, N[i] - '0'); } int r; for (int i = N_N - 1; i >= 0; i--) { if (N[i] - '0' == Max_number) { r = i; break; } } for (int l = 0; l < N_N; l++) { if (N[l] - '0' != Max_number) { if (l < r) { swap(N[l], N[r]); break; } } } cout << N; }