using System; using System.Linq; namespace prob005 { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int s = 0; bool f = false; Array.Sort(c); for (int i = 0; i < b; i++) { s += c[i]; if (s>a) { Console.WriteLine(i); f = true; break; } } if (!f) { Console.WriteLine(b); } } } }