#K51962. Closest Palindromic Number
Closest Palindromic Number
Closest Palindromic Number
Given an integer \(n\), your task is to find the closest palindromic number to \(n\). A palindromic number is one that remains the same when its digits are reversed. If the given number \(n\) is already a palindrome, output \(n\) itself. In case there are two palindromic numbers that are equally distant from \(n\), return the smaller one.
Note: The input is provided via STDIN and the output should be printed to STDOUT. Use the LaTeX format for any mathematical expressions.
inputFormat
The input consists of a single integer \(n\) on one line read from STDIN.
outputFormat
Output a single integer which is the closest palindromic number to \(n\).
## sample123
121