You are given the task of finding palindromic prime numbers.
An integer is said to be a palindrome if it is equal to its reverse. For example, 79197
and 324423
are palindromes.
In this challenge you will be given an integer N
, 1 = N = 1000000
.
You have to find the smallest integer M = N
such that M
is a prime number and M
is a palindrome.
For example, if N
is 64
then the answer is 101
.
Input format
A single integer N
on a single line.
Output format
Your output must consist of a single integer, the smallest prime palindrome greater than or equal to N
.
Constraints
1 <= N <= 1000000