using System; using System.Linq; namespace yukicoder { public class Program { public static void Main(string[] args) { var L = int.Parse(Console.ReadLine()); var N = int.Parse(Console.ReadLine()); var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray(); var sorted = inputs.OrderBy(x => x).ToArray(); int sum = 0; int count = 0; foreach (var item in sorted) { sum += item; if(sum > L) { break; } count++; } Console.WriteLine(count); } } }