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(' '); if (str.Length == 1) Console.WriteLine(1); else { 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 == n) { count++; box += w[count]; } Console.WriteLine(count); } } } }