use std::io::Read; use std::mem; fn gcd(mut x: usize, mut y: usize) -> usize { while x != 0 { y %= x; mem::swap(&mut x, &mut y); } y } fn lcm(x: usize, y: usize) -> usize { let xy_gcd = gcd(x, y); x * y / xy_gcd } fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let n: usize = iter.next().unwrap().parse().unwrap(); let a: usize = iter.next().unwrap().parse().unwrap(); let b: usize = iter.next().unwrap().parse().unwrap(); let c: usize = iter.next().unwrap().parse().unwrap(); let ab_lcm = lcm(a, b); let ac_lcm = lcm(a, c); let bc_lcm = lcm(b, c); let abc_lcm = lcm(a, bc_lcm); println!("{}", n/a + n/b + n/c - n/ab_lcm - n/ac_lcm - n/bc_lcm + n/abc_lcm); }