#include #define rep(i,n) for(int i=0; i<(n); i++) #define rall(x) (x).rbegin(),(x).rend() #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); using namespace std; typedef long long ll; int main(){ string s; cin>>s; int n=s.size(); vector v; rep(i,n){ v.push_back(stoi(s.substr(i,1))); } sort(rall(v)); if(v.size()==2&&v[1]==0){cout << "-1" << endl; return 0;} bool flg=false; while(!flg&&n>1){ n--; if(v[n]!=v[n-1]) flg=true; } if(flg){ int t=v[n-1]; v[n-1]=v[n]; v[n]=t; for(auto x:v) cout << x; cout << endl; } else { cout << "-1" << endl; } }