use prime::*; fn main() { let (n, l): (usize, usize) = get::tuple(); let d = l / (n-1); let ps = primes(d); let ans = ps.iter().map(|p|l-p*(n-1)+1).sum::(); println!("{}", ans) } #[allow(dead_code)] mod prime { pub fn is_prime(n: usize) -> bool { let sq = (n as f64).sqrt().floor() as usize; let p = (2..sq+1).all(|d| n%d != 0); p } pub fn primes(n: usize) -> Vec { if n < 2 {return vec![]} let mut ps = vec![true; n+1]; ps[0] = false; ps[1] = false; for i in 2 .. n+1 { if ps[i] { for k in 2 .. n/i+1 { ps[i*k] = false; } } } ps.iter().enumerate().filter(|&(_,&p)|p).map(|(i,_)|i).collect() } pub fn factorize(n: usize) -> Vec { let sq = (n as f64).sqrt().floor() as usize; let mut fs = vec![]; let mut x = n; for d in 2 .. sq+1 { if x == 1 {break} while x > 1 && x % d == 0 { fs.push(d); x /= d; } } if x != 1 {fs.push(x)}; fs } } #[allow(dead_code)] mod get { use std::io::*; use std::str::*; pub fn val() -> T { let mut buf = String::new(); stdin().read_line(&mut buf).ok(); buf.trim().parse::().ok().unwrap() } pub fn vals(n: usize) -> Vec { let mut vec: Vec = vec![]; for _ in 0 .. n { vec.push(val()); } vec } pub fn tuple() -> (T1, T2) { let mut buf = String::new(); stdin().read_line(&mut buf).ok(); let mut it = buf.trim().split_whitespace(); let x = it.next().unwrap().parse::().ok().unwrap(); let y = it.next().unwrap().parse::().ok().unwrap(); (x, y) } pub fn tuples(n: usize) -> Vec<(T1, T2)> { let mut vec: Vec<(T1, T2)> = vec![]; for _ in 0 .. n { vec.push(tuple()); } vec } pub fn tuple3() -> (T1, T2, T3) { let mut buf = String::new(); stdin().read_line(&mut buf).ok(); let mut it = buf.trim().split_whitespace(); let x = it.next().unwrap().parse::().ok().unwrap(); let y = it.next().unwrap().parse::().ok().unwrap(); let z = it.next().unwrap().parse::().ok().unwrap(); (x, y, z) } pub fn tuple3s(n: usize) -> Vec<(T1, T2, T3)> { let mut vec: Vec<(T1, T2, T3)> = vec![]; for _ in 0 .. n { vec.push(tuple3()); } vec } pub fn list() -> Vec { let mut buf = String::new(); stdin().read_line(&mut buf).ok(); buf.trim().split_whitespace().map(|t| t.parse::().ok().unwrap()).collect() } pub fn lists(h: usize) -> Vec> { let mut mat: Vec> = vec![]; for _ in 0 .. h { mat.push(list()); } mat } }