const fn gcd(a: u64, b: u64) -> u64 { let mut x = (a, b); while x.1 > 0 { x = (x.1, x.0 % x.1); } x.0 } const fn lcm(a: u64, b: u64) -> u64 { a * b / gcd(a, b) } fn main() { let mut xx = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok(); let xx: Vec = xx.split_whitespace().flat_map(str::parse).collect(); println!( "{}", xx[0] / xx[1] + xx[0] / xx[2] + xx[0] / xx[3] - xx[0] / lcm(xx[1], xx[2]) - xx[0] / lcm(xx[1], xx[3]) - xx[0] / lcm(xx[2], xx[3]) + xx[0] / lcm(lcm(xx[1], xx[2]), xx[3]) ); }