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
def is_palindrome(n):
    n = str(n)
    rev_n = n[::-1]
    if n==rev_n:
        return True
    else:
        return False
    
def is_prime(n):
    if n%2==0:
        return False
    count = 0
    sqrt = int(math.sqrt(n)+1)
    i = 3
    while i <= sqrt:
        if n%i == 0:
            count = 1
            break
        i+=2
    if count > 0:
        return False
    else:
        return True        

n = input()
while True:
    if is_prime(n) == True:
        if is_palindrome(n) == True:
            print n
            break
    n+=1