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

#SP0000098. Giúp Hanzo đếm vùng an toàn (Help Hanzo)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Giúp Hanzo đếm vùng an toàn (Help Hanzo)

Help Hanzo

Source: LightOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given integers aa and bb, count the prime numbers in the closed interval [a,b][a,b], including both endpoints. A prime is an integer greater than 11 with exactly two distinct positive divisors, 11 and itself; in particular, 11 is not prime. Output only the number of primes, not the list.

Hanzo must cross territories numbered from aa through bb. A territory is safe exactly when its number is prime. Count the safe territories he may cross.

Input

One line contains two integers aa and bb, the inclusive left and right endpoints of the interval.

Output

Print one integer: the number of primes in the interval.

Subtasks

  • Subtask 1 (20 points): 1≤a≤b≤100001\le a\le b\le 10000; b−a≤500b-a\le 500.
  • Subtask 2 (30 points): 1≤a≤b≤100000001\le a\le b\le 10000000; b−a≤10000b-a\le 10000.
  • Subtask 3 (50 points): 1≤a≤b≤21474836471\le a\le b\le 2147483647; b−a≤100000b-a\le 100000.

Examples

Input

2 36

Output

11

Explanation

The prime-numbered territories from 22 to 3636 are 2,3,5,7,11,13,17,19,23,29,312,3,5,7,11,13,17,19,23,29,31. There are 1111 safe territories, so output 1111. The original Case i: prefix is omitted in this single-instance adaptation.