open System let L = Console.ReadLine() |> int let N = Console.ReadLine() |> int let Wn= Console.ReadLine().Split(' ') |> Array.map (fun i -> i |> int ) |> Array.toList let Wn2 = Wn |> List.sort let mutable sum = 0 let mutable i = 0 for num in Wn do sum <- sum + num if ( sum <= L ) then i <- i + 1 Console.WriteLine i