Fragrant number
Time limit2sMemory limit1024 MB
Given N with up to 10^4 digits, the task is to output the N-th palindrome in increasing order, counting from 1.
- Level
Medium5 of 10
- Topics
- Math, String, Implementation
- Solved
- No attempts yet
Problem
Marat has a wonderful charm, and he can even tell the smell of numbers. This is an extraordinarily rare gift. His grandchildren envy him greatly and keep asking him what each number smells like.
Every number smells different, but some smell especially pleasant. Grandfather Marat loves these the most. The grandchildren took turns handing him number cards, starting from one, and Marat named their scents. The grandchildren marked the numbers that, in their grandfather's opinion, smell especially pleasant. Soon one of the grandchildren noticed that the most fragrant numbers read the same from left to right and from right to left.
Find which fragrant number the grandchildren will mark as the -th.
Input
The only line of input contains one integer , whose length does not exceed digits.
Output
Output one number, the answer to the problem.