let solve l wlst = let rec solve' wlst sumw result = match wlst with | [] -> result | x::xs -> if (x + sumw) > l then result else solve' xs (sumw + x) (result + 1) in let wlst' = List.sort compare wlst in solve' wlst' 0 0 let () = let l = read_line () |> int_of_string and _ = read_line () and wlst = read_line () |> Str.split (Str.regexp_string " ") |> List.map int_of_string in solve l wlst |> string_of_int |> print_endline