Wonderful!#3357

Wonderful!

1 second
64 megabytes
Very easy (≈850)

A number is called wonderfully-prime if it is a prime number (only divisible by itself and ), and when its digits are reversed, the resulting number is a different prime number. Your task is to output the -th wonderfully-prime number. If this number exceeds 10^6, output .

Input

The input consists of a single integer (1 \le K \le 1000).

Output

The output should be a single integer, which is the answer to the problem.

Examples

Example 1

Loading
Loading