PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000085. Đếm số DePrime (Count DePrimes)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm số DePrime (Count DePrimes)

Count DePrimes

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer is a DePrime when the sum of its distinct prime divisors is prime. For example, 10=2⋅510=2\cdot5 gives 2+5=72+5=7, and 12=22⋅312=2^2\cdot3 gives 2+3=52+3=5; both are DePrimes. Given a,ba,b, count the DePrimes in the inclusive range [a,b][a,b].

Input

One line contains two integers a,ba,b.

Output

Print the number of DePrimes in [a,b][a,b].

Subtasks

  • Subtask 1 (20 points): 2≤a≤b≤10002\le a\le b\le 1000.
  • Subtask 2 (30 points): 2≤a≤b≤1000002\le a\le b\le 100000.
  • Subtask 3 (50 points): 2≤a≤b≤50000002\le a\le b\le 5000000.

Examples

Input

10 21

Output

9

Explanation

The DePrimes in [10,21][10,21] are 10,11,12,13,16,17,18,19,2010,11,12,13,16,17,18,19,20. In particular, 16=2416=2^4 contributes the single distinct prime divisor 22 and qualifies; 21=3⋅721=3\cdot7 gives the composite sum 1010. Thus the answer is 99.