cho.sh
Notes
Loading...

Prime Palindrome

Time limit

2s

Memory limit

256 MB

Problem

An integer is called a palindrome number if it reads the same from left to right and from right to left. For example, 79,197 and 324,423 are palindrome numbers.

Given an integer N (1 ≤ N ≤ 1,000,000), write a program that finds the smallest integer greater than or equal to N that is both prime and a palindrome number.

Input

The first line contains N.

Output

Print the number that satisfies the conditions.