//Normal #define _GLIBCXX_DEBUG #define ll long long #include using namespace std; using Graph = vector>; void print(auto a){ cout << a; } void prints(auto a){ cout << a << " "; } void prints(){ cout << " "; } void printl(auto a){ cout << a << endl; } void printl(){ cout << endl; } void fix(int n){ cout << fixed << setprecision(n); } int siz(string s){ return (int)s.size(); } int main(){ string S; cin >> S; int s = (int)S.size(); int nZ = 0; sort(S.rbegin(), S.rend()); for(int i = 0; i < s; i++){ int j = S[i]-'0'; if(j != 0) nZ++; } if(S[0] == S[s-1] or nZ == 1){ printl(-1); }else{ for(int i = s-2; i >= 0; i--){ if(S[i] != S[s-1]){ swap(S[i], S[i+1]); printl(S); return 0; } } } }