#include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); string x; cin >> x; int n = x.size(); sort(x.begin(), x.end()); for (int i = 1; i < n; i++) { if (x[i - 1] != x[i]) { swap(x[i - 1], x[i]); if (x.back() == '0') break; reverse(x.begin(), x.end()); cout << x << endl; exit(0); } } cout << -1 << endl; return 0; }