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 is_prime(number):
	if number == 1: return False
	if number == 2 or number == 3: return True
	if number % 2 == 0: return False
	for i in range(3, number/2+2,2):
		if number % i == 0:
			return False 
	return True
def is_pallindrome(number):
	if len(number) < 2:
		return True
	else:
		return number[0] == number[-1] and is_pallindrome(number[1:-1])

number = int(raw_input())
while number > 0:
	if is_pallindrome(str(number)):
		if is_prime(number):
			print number
			break
	number += 1