Problem E. Prime Prime Prime

Problem

A positive integer is a prime if it has no other factors besides 1 and itself. A paliprime is a prime number such that its reverse is also a prime number. For example, 17, 71, 79, 97 are paliprimes; but 23, 41, 43, 61 are not. Write a program to report the number of paliprimes in a given range of numbers.

Input

The input consists of many pairs of positive integers such that the first one is no bigger than the second. The maximum possible integer is 1000000.

Output

For each input, print the number of paliprimes within the given range inclusively.

Sample input

1 10
13 79
90 100
1000 2000

Sample Output

4
7
1
60