using System; using System.Linq; namespace No5 { class Program { static void Main(string[] args) { var L = int.Parse(Console.ReadLine()); var N = int.Parse(Console.ReadLine()); var Ws = Console.ReadLine().Split(' ').Select(i => int.Parse(i)); var orderd = Ws.OrderBy(i => i).ToArray(); var total = 0; var result = 0; foreach (var W in orderd) { total += W; if (total > L) break; result++; } Console.WriteLine(result); } } }