#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); string S; cin >> S; int k = S.size(); sort(all(S)); reverse(all(S)); swap(S[k-1],S[k-2]); if(S[k-1] == S[k-2] || S[0] == '0'){ cout << -1 << endl; return 0; } cout << S << endl; return 0; }