#include using namespace std; #include using namespace atcoder; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair #define LP pair int main() { string x; cin >> x; sort(x.begin(), x.end()); reverse(x.begin(), x.end()); for (int i = x.size()-1; i >= 1; i--) { if (x[i] != x[i-1]) { if (i-1>0 || x[i] != '0') { swap(x[i],x[i-1]); cout << x << endl; return 0; } } } cout << -1 << endl; }