#P7588. Double Prime Count

    ID: 20782 Type: Default 1000ms 256MiB

Double Prime Count

Double Prime Count

A prime number is a natural number greater than $1$ that has no positive divisors other than $1$ and itself. A double prime number is defined as a prime number whose sum of digits is also prime.

Given a closed interval $[L, R]$, your task is to determine the number of double prime numbers within that interval.

Note: The digit-sum of a number is obtained by summing all its digits. For example, the digit-sum of $29$ is $2+9=11$, and since $11$ is prime, $29$ is a double prime if it is prime.

inputFormat

The input consists of a single line containing two integers $L$ and $R$ ($1 \leq L \leq R \leq 10^6$), representing the lower and upper bound of the interval respectively.

outputFormat

Output a single integer: the number of double prime numbers in the interval $[L, R]$.

sample

1 30
7