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 where F: FromStr { // FromStr has type Error in its struct. // https://doc.rust-lang.org/std/str/trait.FromStr.html // String#parse return Result, // and unwrap is only available in Result match read_line().parse::() { Ok(v) => v, Err(_) => panic!("failed to parse.") } } fn read_many() -> Vec where F: FromStr { read_line().split(' ').map( |s| match s.parse::() { 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 = 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) }