#CCBCHBA0000126. Đếm số nguyên tố trong [L,R] (Count Primes in an Interval)

Đếm số nguyên tố trong [L,R] (Count Primes in an Interval)

Count Primes in an Interval

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given 0≤L≤R≤200000\le L\le R\le20000, count primes in the inclusive interval [L,R][L,R]. A prime is an integer greater than 1 with exactly two positive divisors. Neither 0 nor 1 is prime. Use direct trial division; a sieve or array is unnecessary.

Input

One line contains integers L,RL,R.

Output

Print the number of primes in the inclusive interval.

Subtasks

  • Subtask 1 (20%): 0≤L≤R≤1000\le L\le R\le 100.

  • Subtask 2 (30%): 0≤L≤R≤20000\le L\le R\le 2000.

  • Subtask 3 (50%): 0≤L≤R≤200000\le L\le R\le 20000.

Examples

Example 1

Input:

0 10

Output:

4

Explanation:

Count only numbers at least 2 with no divisor up to their square root.

Example 2

Input:

1 1

Output:

0

Explanation:

Count only numbers at least 2 with no divisor up to their square root.