let memo f = let dict = new System.Collections.Generic.Dictionary<_,_>() let memFunc input = match dict.TryGetValue input with | true,x -> x | false,_ -> let ans = f input dict.Add(input,ans) ans memFunc let rec memF = let f = function | 0L -> 1L | x -> memF (x/3L) + memF (x/5L) memo f let N = stdin.ReadLine() |> int64 memF N |> printfn "%i"