#include using namespace std; #define ll long long typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #define M 1000000007 #define all(a) (a).begin(),(a).end() #define rep(i,n) reps(i,0,n) #define reps(i,m,n) for(int i=(m);i<(n);i++) int main(){ string s;cin>>s; sort(all(s),greater()); string t=s; for(int i=t.size()-1;i>0;i--){ if(t[i]!=t[i-1]){ swap(t[i],t[i-1]); break; } } if(s==t|| t[0]=='0')cout<<-1<