Prime number#242

Prime number

1 second
64 megabytes
Easy

A natural number is called a derivative of a natural number if either coincides with or can be obtained by deleting some digits from the decimal representation of . For example, the derivatives of the number are , , , , , , , , , , and .

Given a natural number , determine the largest prime number which is a derivative of . If none of the derivatives of is prime, take P = 0. A natural number is called prime if P \neq 1 and has no divisors other than and .

Input

The only line of input contains the number (0 < N < 10^9).

Output

The program should output the number .

Examples

Example 1

Loading
Loading