using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicore { class Program { static void Main(string[] args) { int boxSize = int.Parse(Console.ReadLine()); Console.ReadLine(); int[] blockSizes = Console.ReadLine() .Split(' ') .Select(x => int.Parse(x)) .ToArray(); Array.Sort(blockSizes); int sum = 0; int cnt = 0; foreach (var blockSize in blockSizes) { sum += blockSize; if(sum>=boxSize) break; cnt++; } Console.WriteLine(cnt); } } }