#K34512. Largest Numeric Palindrome Less Than N

    ID: 25326 Type: Default 1000ms 256MiB

Largest Numeric Palindrome Less Than N

Largest Numeric Palindrome Less Than N

You are given an integer ( n ) such that ( n > 9 ). Your task is to find the largest numeric palindrome strictly less than ( n ). A number is said to be a palindrome if it reads the same forwards and backwards, i.e. ( x ) is a palindrome if ( x = \text{reverse}(x) ).

For example, if ( n = 123 ), the largest palindrome less than 123 is 121. Note that for inputs close to 10, e.g. ( n = 10 ), the answer is defined as 9.

inputFormat

The input consists of a single integer ( n ) (with ( n > 9 )) provided via standard input.

outputFormat

Output a single integer representing the largest numeric palindrome less than ( n ) to standard output.## sample

123
121