#include #include #include #include #include using namespace std; vector digits; vector orders; int n_digits; int get_num(int a, int b) { auto tmp = digits; swap(tmp[a], tmp[b]); int num = 0; for (int i = 0; i < n_digits; i++) { num += tmp[i] * orders[i]; } return num; } int main() { int n; cin >> n; int ans = n; while (n > 0) { digits.push_back(n % 10); n /= 10; } n_digits = digits.size(); orders.assign(n_digits, 0); orders[0] = 1; for (int i = 1; i < n_digits; i++) { orders[i] = 10 * orders[i - 1]; } for (int i = 0; i < n_digits; i++) { for (int j = i + 1; j < n_digits; j++) { ans = max(ans, get_num(i, j)); } } cout << ans << endl; return 0; }