//---------- begin union_find ---------- #[allow(dead_code)] mod union_find { pub struct UF { p: Vec, } impl UF { pub fn new(n: usize) -> UF { UF {p: vec![-1; n] } } pub fn init(&mut self) { for p in self.p.iter_mut() { *p = -1; } } pub fn root(&mut self, mut x: usize) -> usize { while self.p[x] >= 0 { let p = self.p[x] as usize; if self.p[p] < 0 { return p; } let q = self.p[p] as usize; self.p[x] = q as i32; x = q; } x } pub fn unite(&mut self, mut x: usize, mut y: usize) -> Option<(usize, usize)> { x = self.root(x); y = self.root(y); if x == y { return None; } if self.p[x] > self.p[y] { let s = x; x = y; y = s; } self.p[x] += self.p[y]; self.p[y] = x as i32; Some((x, y)) } } } //---------- end union_find ---------- fn run() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let l: usize = it.next().unwrap().parse().unwrap(); let r: usize = it.next().unwrap().parse().unwrap(); let mut ans = r - l; let mut u = union_find::UF::new(r + 1); for i in l..=r { let mut j = 2 * i; while j <= r { if u.unite(i, j).is_some() { ans -= 1; } j += i; } } println!("{}", ans); } fn main() { run(); }