#include int main() { int N; int p[10] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; int S; int temp; int a, b; int ans = -1; std::cin >> N; ans = N; temp = N; S = 0; while( temp != 0 ) { S += 1; temp /= 10; } for(int i = 0; i < S; ++i) { for(int j = i+1; j < S; ++j) { temp = N; a = (N / p[i]) % 10; b = (N / p[j]) % 10; temp -= a * p[i]; temp -= b * p[j]; temp += b * p[i]; temp += a * p[j]; ans = std::max(ans, temp); } } std::cout << ans << std::endl; return 0; }