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_prime(a):
	x = True
	if a%2 ==0:
		x=(a==2)
	else:
		t= int(math.sqrt(a))+1
		i = 3
		while i < t:
		
			if a%i == 0:
				x = False
				break
			i+=2
	return x
def rev(x):
        result=0
        i=0
        while x/10 > 0:
                result = (result * 10) + (x % 10)
                x = x/10
        result = (result * 10) + (x % 10)
        return result
x = int(raw_input())
if x%2 == 0:
	x+=1
while True:
	if rev(x)== x:
		if is_prime(x):
			print x
			break
	x+=2