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,box=0; for (count = 0; box < l || n < count; count++) { box += w[count]; } Console.WriteLine(count-1); } } }