#include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair Pii; const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); string x; cin >> x; int l = x.length(); map count; for (auto &c: x) count[c]++; if (count.size() == 1 || count['0'] >= l-1) { cout << -1 << endl; // impossible return 0; } sort(x.begin(), x.end()); int p = 1; while (x[p] == x[0]) p++; swap(x[0], x[p]); reverse(x.begin(), x.end()); cout << x << endl; return 0; }