Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/sonlar-katta-oraliqdagi-tublar

Primes in a large segment

Medium 1000 ms 128 MB 58%
Share

You are given two positive integers $l$ and $r$. How many primes are there from $l$ to $r$ (inclusive)? The numbers are large, but the segment is not very long.

A segment of the number line; the primes in it are highlighted, the rest are crossed out as multiples of small primes

Input

One line with two positive integers: $l$ and $r$.

Output

One integer — the number of primes in the segment.

Note

$1 \le l \le r \le 10^{12}$
$r - l \le 10^{5}$

Examples

Input #1
10 30
Output #1
6
Input #2
1 1
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.