#include #include #include using namespace std; int main() { string s; cin >> s; int n[s.length()]; for (int i = 0; i < s.length(); i++) { n[i] = s[i] - '0'; } int ns[s.length()]; copy(n, n+s.length(), ns); sort(ns, ns+s.length(), greater()); for(int i = 0; i < 8; i++) { if (n[i] < ns[i]) { for (int j = 8; j > i; j--) { if (ns[i] == n[j]) { n[j] = n[i]; n[i] = ns[i]; break; } } break; } } for(int i = 0; i < s.length(); i++){ if (n[i] == 0) { break; } cout << n[i]; } cout << endl; }