#include using namespace std; int main() { string S; cin >> S; sort(S.rbegin(), S.rend()); int s = 0; for (int i = S.size() - 1; i > 0; i--) if (S.at(i) != S.at(i - 1) && !s) swap(S.at(i), S.at(i - 1)), s = 1; cout << ((s && S.front() != '0') ? S : "-1") << "\n"; }