#include "bits/stdc++.h" #pragma GCC optimize("Ofast") // Begin {{{ using namespace std; #ifndef DEBUG #define dump(...) #endif template inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } template inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } template inline vector make_v(const T &initvalue, intmax_t sz) { return vector(sz, initvalue); } template inline auto make_v(const T &initvalue, intmax_t sz, Args... args) { return vector(initvalue, args...))>(sz, make_v(initvalue, args...)); } constexpr int INF = 0x3f3f3f3f; constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL; // }}} End signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string x; cin >> x; sort(x.rbegin(), x.rend()); if (x == string(x.length(), x[0])) { cout << -1 << "\n"; } else if (x.substr(1, x.length() - 1) == string(x.length() - 1, '0')) { cout << -1 << "\n"; } else { for (size_t i = x.length() - 1; i >= 1; --i) { if (x[i] != x[i - 1]) { swap(x[i], x[i - 1]); break; } } cout << x << "\n"; } return 0; }