An integer is said to be a palindrome if it is equal to its
reverse.  For example, 79197 and 324423 are palindromes. In this task
you will be given an integer N, 1 ≤ N ≤ 1000000.  You must find
the smallest integer M ≥ N such that M is a prime number and M is a
palindrome.  
For example, if N is 31 then the answer is 101.

Input
A single integer N, (1 ≤ N ≤ 1000000), on a single line.

Output
Your output must consist of a single integer, the smallest prime
palindrome greater than or equal to N.

Example

Input:
31
Output:
101
import math
n=input()
if n&1==0:
    n+=1   
found=0
def checkPrime(x):
    if x<=1:
        return 0
    if x%2==0:
        return 0
    else:
        root=int(math.sqrt(x))+1
        for i in range(3,root,2):
            if x%i==0:
                return 0    
        else:
            return 1
        
while not found:
    if checkPrime(n):
        if str(n)==str(n)[::-1]:
            print n
            found=1
        else:
            n+=2
    else:
        n+=2