using System; namespace No._5 { class Program { static void Main(string[] args) { int L = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); var width = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Array.Sort(width); int weight = 0; int count = 0; for (var i = 0; i < N; i++) { weight += width[i]; if (weight <= L) count++; else break; } Console.WriteLine(count); } } }