use std::io; use std::str::FromStr; use std::fmt; fn read_line() -> String { let mut ret = String::new(); io::stdin().read_line(&mut ret).expect("read_line failed"); ret.trim().to_string() } fn read_one<F>() -> F where F: FromStr { // FromStr has type Error in its struct. // https://doc.rust-lang.org/std/str/trait.FromStr.html // String#parse return Result<F, F::Err>, // and unwrap is only available in Result<T, Result> match read_line().parse::<F>() { Ok(v) => v, Err(_) => panic!("failed to parse.") } } fn read_many<F>() -> Vec<F> where F: FromStr { read_line().split(' ').map( |s| match s.parse::<F>() { Ok(v) => v, Err(_) => panic!("failed to parse.") } ).collect() } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- fn gcd(x: i64, y: i64) -> i64 { if y == 0 { x } else { gcd(y, x%y) } } fn lcm(x: i64, y: i64) -> i64 { x * y / gcd(x, y) } fn main() { let n: i64 = read_one(); let v: Vec<i64> = read_many(); let (a, b, c) = (v[0], v[1], v[2]); let ans = (n/a)+(n/b)+(n/c)-(n/lcm(a,b))-(n/lcm(b,c))-(n/lcm(c,a))+(n/lcm(lcm(a,b),c)); println!("{}", ans) }