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
#PRPALIN
def isprime(i):
    if(i%2==0 or i%3==0 or i==1):
        return False
    bo=True
    for j in range(5,int(i**0.5),2):
        if(i%j==0):
            bo=False
            break
    return bo
    
n=input()
i=n
if(i%2==0):
    i+=1
while(1):
    s=str(i)
    l=len(s)
    bo=True
    #print i
    for j in range(l/2):
        if(s[j]!=s[l-j-1]):
            bo=False
            break
    if(bo):
        if(isprime(i)==False):
            bo=False
    if(bo):
        print i 
        break
    i+=2