#include #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; int main() { string x, y; cin >> x; y = x; sort(all(x), greater()); if (x[0] == '0') { cout << -1 << endl; return 0; } swap(y[y.size()-1], y[y.size()-2]); if (y[0] == '0') { cout << -1 << endl; return 0; } if (y == x) { cout << -1 << endl; return 0; } cout << y << endl; }