let inline pow b e = let rec iter e acc = match e with | i when i = LanguagePrimitives.GenericZero -> acc | _ -> iter (e - LanguagePrimitives.GenericOne) (acc * b) iter e LanguagePrimitives.GenericOne let rec product lst = match lst with | [] -> Seq.singleton [] | x::xs -> Seq.collect (fun y -> product xs |> Seq.map (fun z -> y::z)) x let count n = List.replicate 5 [0L;1L] |> product |> Seq.map (fun e -> Seq.zip [3L;5L;17L;257L;65537L] e |> Seq.map (fun e -> pow (fst e) (snd e)) |> Seq.reduce (*)) |> Seq.filter (fun e -> e <> 1L && e <= 1000000000L) |> Seq.append [4L] |> Seq.map (fun i -> Seq.initInfinite (fun e -> pow 2L e) |> Seq.takeWhile (fun e -> i * e <= n) |> Seq.length) |> Seq.sum stdin.ReadLine () |> int64 |> count |> printfn "%d"