#include using namespace std; void no_927(void) { string x; cin >> x; sort(x.begin(), x.end()); reverse(x.begin(), x.end()); int x_size = (int)x.size(); bool is_swap = false; for (int i = x_size - 2; i >= 0; i--) { if (x[x_size - 1] != x[i]) { swap(x[i], x[x_size - 1]); is_swap = true; break; } } if (!is_swap) { cout << "-1" << endl; return; } if (x[0] == '0') { cout << "-1" << endl; return; } cout << x << endl; } int main(void) { no_927(); return 0; }