using System; public class Program { public static void Main(string[] args) { int l = int.Parse(Console.ReadLine()); Console.ReadLine(); string[] s = Console.ReadLine().Split(' '); int[] w = new int[s.Length]; for (int i = 0; i < w.Length; i++) { w[i] = int.Parse(s[i]); } Array.Sort(w); int count = 0; for (int i = 0; i < w.Length; i++) { if (l - w[i] >= 0) { l -= w[i]; count++; } } Console.WriteLine(count); } }