open System let ri () = stdin.ReadLine() |> int let ria () = stdin.ReadLine().Split() |> Array.map int let rl () = stdin.ReadLine() |> int64 let rla () = stdin.ReadLine().Split() |> Array.map int64 let rec gcd (s:int64) (t:int64) :int64 = match s with | 0L -> t | _ -> gcd (t%s) s let lcm (s:int64) (t:int64) :int64 = s * t / (gcd s t) type Sol() = member this.Solve() = let N = rl () let [|a; b; c|] = rla () let mutable sum = N sum <- [a;b;c] |> Seq.sumBy (fun x -> N/x ) sum <- sum - ([(a,b);(b,c);(c,a)] |> Seq.sumBy (fun (x,y) -> N / (lcm x y) ) ) sum <- sum + (N / (Seq.reduce lcm [a;b;c])) sum |> printfn "%d" let mySol = new Sol() mySol.Solve()