Under construction

Still being built. Things may change

Fragrant number

Time limit2sMemory limit1024 MB

Summary
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 NN-th.

Input

The only line of input contains one integer NN, whose length does not exceed 10410^4 digits.

Output

Output one number, the answer to the problem.

Examples1

  1. Example 1

    Input
    10
    
    Expected output
    11