#include #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef pairP; const int MOD=1000000007; const int INF=0x3f3f3f3f; const ll INFL=0x3f3f3f3f3f3f3f3f; int main(){ string s;cin>>s; sort(s.begin(),s.end(),greater<>()); bool ok=false; for(int i=s.size()-2;i>=0;i--){ if(s[i]!=s.back()&&s[i]!='0'){ swap(s[i],s.back()); ok=true; break; } } if(!ok)puts("-1"); else cout<