using System; namespace csharptest { class Program { static void Main(string[] args) { int l = int.Parse(Console.ReadLine()); int n = int.Parse(Console.ReadLine()); int[] w = new int[n]; string[] str = Console.ReadLine().Split(' '); for (int m = 0; m < str.Length; m++) { w[m] = int.Parse(str[m]); } Array.Sort(w); int count = -1, box = 0; while (l > box) { count++; box += w[count]; } Console.WriteLine(count); } } }