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 sys

t = int(sys.stdin.readline())
def ispalin(x):
    if x<10:
        return True
    strx = str(x)
    for a in range(int(len(strx)/2)):
        if strx[a]!=strx[-a-1]:
            return False
    return True

def isprime(x):
    if x==2:
        return True
    for a in range(2, int(x/2)):
        if x % a ==0:
            return False
    return True

while True:
    if ispalin(t) and isprime(t):
        print t
        break
    t+=1