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
def checkPalin( A ) :
    s = str(A)
    return True if s == s[::-1] else False

def isPrime( A ) :
    flag = 1
    if A == 1 : 
        return True
    if A % 2 == 0 or A < 2 :
        return False
    for i in xrange( 3 , int(A**0.5)+ 1, 2 ) :
        if A % i == 0 :
            flag = 0
    return True if flag == 1 else False

n = int(raw_input() )
n = n+1 if n % 2 == 0 else n
while True :
    if str(n) == str(n)[::-1] :
        if isPrime(n) :
            print n
            break
    n += 2