#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef string::const_iterator State; #define Ma_PI 3.141592653589793 #define eps 1e-5 #define LONG_INF 2000000000000000000LL #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007LL #define GYAKU 500000004LL #define MOD 998244353LL #define seg_size 262144 #define REP(a,b) for(long long a = 0;a < b;++a) int main(){ string x; cin >> x; sort(x.begin(), x.end()); reverse(x.begin(), x.end()); for (int i = x.size() - 1; i >= 0; --i) { if (x[i] != '0') { int ok = 0; for (int q = i - 1; q >= 0; --q) { if (x[q] != '0'&&x[q] != x[i]) { swap(x[q], x[i]); ok = 1; break; } } if (ok == 0) { x = "-1"; } cout << x << endl; return 0; } } cout << -1 << endl; }