#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)); vector v2=v; UNIQUE(v2); if(v2.size()==1||v2[1]==0){cout << "-1" << endl; return 0;} n=v[v.size()-2]; v[v.size()-2]=v[v.size()-1]; v[v.size()-1]=n; for(auto x:v) cout << x; cout << endl; }