#include using namespace std; int num[1010101]; int main() { string s; cin >> s; for (int i = 0; i < s.size(); ++i) { num[i] = s[i] - '0'; } sort(num, num+s.size()); for (int i = 0; i < s.size() - 2; ++i) { if (num[i] != num[i+1]) { swap(num[i], num[i+1]); for (int j = s.size()-1; j >= 0; --j) cout << num[j]; cout << endl; return 0; } } cout << -1 << endl; return 0; }