//#define _GLIBCXX_DEBUG #include "bits/stdc++.h" using namespace std; //------------------------------- Libraries --------------------------------// //------------------------------- Type Names -------------------------------// using i64 = int_fast64_t; using seika = string; //{akari : 1D, yukari : 2D, maki : 3D} vector template using akari = vector; template using yukari = akari>; template using maki = akari>; //{akane : ascending order, aoi : decending order} priority queue template using akane = priority_queue, greater>; template using aoi = priority_queue; //------------------------------- Dubug Functions ---------------------------// inline void print() { cout << endl; } template void print(const First &first, const Rest &... rest) { cout << first << ' '; print(rest...); } //------------------------------- Solver ------------------------------------// void solve() { seika s; cin >> s; sort(s.begin(), s.end()); int x = 1, n = s.size(); while (x < n && s[0] == s[x]) { x++; } if (x == n || (x == n - 1 && s[0] == '0')) { cout << -1 << endl; return; } swap(s[x - 1], s[x]); reverse(s.begin(), s.end()); cout << s << endl; } int main() { solve(); return 0; }