This page is still under construction.

Parts of this page are still being built. What you see may change.

Upside-down prime

Time limit3sMemory limit256 MB

Summary
Check whether N and its 180-degree rotation are both prime, where digits 3, 4 and 7 make the rotation invalid.
Level

Medium6 of 10

Topics
Number theory, Implementation
Solved
No attempts yet

Problem

I knocked my alarm clock over in my sleep, and 08:15 had turned into 51:80. Some digits on a digital display are still digits after you turn them 180 degrees.

Turning a single digit 180 degrees gives this.

  • 0, 2, 5 and 8 keep their shape.
  • 1 keeps its shape and moves to the other side of its place.
  • 6 becomes 9, and 9 becomes 6.
  • 3, 4 and 7 turn into shapes that are not digits.

Turning the whole number also reverses the order of the places. Turning 18115211 by 180 degrees gives 11251181. A zero at the front of the result is not read.

The numbers I like are primes. Decide whether NN is prime and whether the number obtained by turning NN 180 degrees is prime as well. If NN contains a 3, a 4 or a 7, the rotation is not a number, so NN fails the condition.

Input

The first line contains NN (1≤N≤10161 \le N \le 10^{16}).

The first digit of NN is not 0.

Output

Print yes on the first line if NN is prime and the number obtained by turning it 180 degrees is prime as well. Otherwise print no.

Examples3

  1. Example 1

    Input
    151
    
    Expected output
    yes
    
  2. Example 2

    Input
    23
    
    Expected output
    no
    
  3. Example 3

    Input
    18115211
    
    Expected output
    no