open System let solve l ws = ws |> Array.sort |> Array.scan (+) 0 |> Array.where (fun x -> x <= l) |> Array.length |> fun x -> x - 1 let R() = Console.ReadLine() let L = R() |> int let N = R() |> int let W = R().Split() |> Array.map int solve L W |> Console.WriteLine