#K366. Twin Primes Count

    ID: 25790 Type: Default 1000ms 256MiB

Twin Primes Count

Twin Primes Count

In this problem, you are given two integers L and R. Your task is to count the number of twin prime pairs in the inclusive interval [L, R]. Two prime numbers p and q form a twin prime pair if (q - p = 2) and both are prime. For example, in the interval [3, 13], the twin prime pairs are (3, 5), (5, 7), and (11, 13), so the answer is 3. You might find the Sieve of Eratosthenes algorithm helpful for generating all prime numbers up to R.

inputFormat

The input consists of a single line containing two space-separated integers L and R representing the lower and upper bounds of the interval.

outputFormat

Output a single integer – the number of twin prime pairs in the interval [L, R].## sample

3 13
3