#include using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() const int mod=1000000007,MAX=100005,INF=1<<30; int main(){ string S;cin>>S; sort(all(S)); reverse(all(S)); bool ok=true; for(int i=S.size()-1;i>=1;i--){ if(S[i]!=S[i-1]&&(i>=2||S[i]!='0')){ ok=false; swap(S[i],S[i-1]); break; } } if(ok) cout<<-1<