#B2136. Count Palindromic Primes

    ID: 11218 Type: Default 1000ms 256MiB

Count Palindromic Primes

Count Palindromic Primes

Given an integer n, count the number of integers between 11 and n (inclusive) which are both prime and palindromic. An integer p is a prime number if it has no divisors other than 1 and p itself. An integer is palindromic if it reads the same backwards as forwards. In mathematical notation, you need to count the number of integers p in the interval [11, n] such that:

\( \text{isPrime}(p) = \text{true} \) and \( p = \text{reverse}(p) \).

For example, 11 is both a prime and a palindrome.

inputFormat

The input contains a single integer n (n \(\geq\) 11) representing the upper limit of the interval.

outputFormat

Output a single integer representing the count of numbers between 11 and n (inclusive) that are both prime and palindromic.

sample

11
1