#include using namespace std; int main(){ string x; cin >> x; sort(x.begin(), x.end(), greater()); int n = x.size(); if(x[0] == x[n-1] || x[1] == '0'){ cout << -1 << endl; return 0; } int i; for(i = n-1;i >= 0;i--){ if(x[n-1] != x[i]){ swap(x[i], x[i+1]); break; } } cout << x << endl; return 0; }