#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int main(){ ll N; cin >> N; vector v; while(N>0){ v.push_back(N%10); N/=10; } reverse(ALLOF(v)); ll ret = N; rep(i,v.size()){ REP(j,i+1,v.size()){ swap(v[i], v[j]); ll tmp = 0; rep(k,v.size()) tmp = 10*tmp + v[k]; ret = max(ret, tmp); swap(v[i], v[j]); } } cout << ret << endl; return 0; }