#include using namespace std; int main() { ios::sync_with_stdio(false); string X; cin >> X; sort(X.begin(), X.end()); reverse(X.begin(), X.end()); for (int i = X.size() - 2; ~i; --i) { if (X[i] != X[i + 1]) { if (i == 0 && X[i + 1] == '0') continue; swap(X[i], X[i + 1]); cout << X << endl; return 0; } } cout << -1 << endl; return 0; }