#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { std::string s; cin >> s; sort(begin(s), end(s)); reverse(begin(s), end(s)); if(s.front() == s.back()) { printf("-1\n"); return 0; } for(int i = (int)s.size() - 2; i >= 0; i--) { if(s[i] == s[i + 1]) continue; std::swap(s[i], s[i + 1]); break; } if(s.front() == '0') { printf("-1\n"); return 0; } printf("%s\n", s.c_str()); return 0; }