Prime number
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
A natural number X
is considered a derivative of another natural number N
if X
is either identical to N
or can be formed by removing some digits from the decimal representation of N
. For instance, the derivatives of the number 1024 include 1, 2, 4, 10, 12, 14, 24, 102, 104, 124, and 1024. Given a natural number N
, your task is to find the largest prime number P
that is a derivative of N
. If none of the derivatives of N
are prime, then P
should be set to 0. A natural number P
is defined as prime if P≠1 and it has no divisors other than 1 and P
itself.
Input
The input consists of a single line containing the number N
(0 < N < 10^9
).
Output
The output should be the number P
.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 32%