#include using namespace std; int main() { string S; cin >> S; int N = S.size(); sort(S.rbegin(), S.rend()); for (int i = N - 1; i >= 1; i--) { if (S[i] != S[i - 1]) { swap(S[i], S[i - 1]); if (S[0] != '0') { cout << S; return 0; } else { cout << -1; return 0; } } } cout << -1; return 0; }