let split (s:string) = s.Split ' ' let f = split >> Seq.map int >> Seq.last let g = split >> Seq.map int >> Seq.sort let count = let m = stdin.ReadLine () |> f let sq = stdin.ReadLine () |> g let rec iter acc c = match (m - acc) with | i when i < 0 -> c - 1 | i when i = 0 -> c | _ -> iter (acc + Seq.nth c sq) (c + 1) iter 0 0 count |> printfn "%d"