#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::(); let (l, r) = (v[0], v[1]); let primes = get_primes(35000); // debug!(primes.len()); let mut squares = primes.iter().map(|&x| x * x).collect::>(); let mut divided = vec![false; (r - l + 1) as usize]; for &p in &squares { let mut cur = l / p * p; while cur <= r { if cur >= l { divided[(cur - l) as usize] = true; } cur += p; } } let ans = divided.iter().filter(|&&x| !x).count(); println!("{}", ans); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn get_primes(n: i64) -> Vec { let mut is_prime = vec![true; n as usize + 1]; let mut primes = Vec::new(); is_prime[0] = false; is_prime[1] = false; for i in 2..n + 1 { if is_prime[i as usize] { primes.push(i); let mut j = 2 * i; while j <= n { is_prime[j as usize] = false; j += i; } } } primes }