#include #include #include using namespace std; int main() { string str; cin >> str; int n = (int)str.size(); int x = 0; while(x < n){ int maxIdx = n; for(int i = n - 1; i > x; i--){ if(str[i] > str[maxIdx]){ maxIdx = i; } } bool isSwapped = false; for(int i = 0; i < n; i++){ if(!isSwapped && str[maxIdx] > str[i] && maxIdx > i){ swap(str[maxIdx], str[i]); isSwapped = true; } } if(isSwapped) break; else x++; } long long ans = atoll(str.c_str()); cout << ans << endl; return 0; }