#include using namespace std; int main() { string s; cin >> s; int n = s.size(); sort(s.rbegin(), s.rend()); if (n == 1 || s[1] == '0') { cout << -1 << endl; return 0; } string tmp = s; for (int i = n - 2; 0 <= i; i--) { if (s[i] != s[i + 1]) { swap(s[i], s[i + 1]); break; } } if (s == tmp) { cout << -1 << endl; } else { cout << s << endl; } return 0; }