using System; public class Program{ public static void Main(){ int width = int.Parse(Console.ReadLine() ?? string.Empty); int block = int.Parse(Console.ReadLine() ?? string.Empty); string[] blockWidth = (Console.ReadLine() ?? string.Empty).Trim().Split(' '); for(int i = 0; i< block;i++) { for(int j = 0; j < block-1;j++) { if(int.Parse(blockWidth[j]) > int.Parse(blockWidth[j+1])) { string box = blockWidth[j]; blockWidth[j] = blockWidth[j+1]; blockWidth[j + 1] = box; } } } int count = 0; for(int i = 0; i < block;i++) { width=width - int.Parse(blockWidth[i]); if(width < 0) { Console.WriteLine("{0}",count); return; } count++; } } }