#include using namespace std; typedef long long ll; int main() { string s; cin >> s; sort(s.begin(), s.end()); int mi = s[0]; int pos = -1; for (int i = 1; i < s.size(); ++i) { if (s[i] != mi) { pos = i; break; } } if (pos == -1) { puts("-1"); return 0; } swap(s[0], s[pos]); reverse(s.begin(), s.end()); if (s[0] == '0') { puts("-1"); } else { cout << s << '\n'; } return 0; }