using System; public class Hello{ static void Ascsort(int[] a){ for(int i = 0;i < a.Length - 1;i++){ for(int j = i + 1;j < a.Length;j++){ if(a[i] > a[j]){ int temp; temp = a[i]; a[i] = a[j]; a[j] = temp; } } } } public static void Main(){ int L = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] block = new int[N]; for(int x = 0;x < N;x++){ block[x] = int.Parse(input[x]); } Ascsort(block); int count = 0; while(L - block[count] >= 0){ L -= block[count]; count++; } Console.WriteLine(count); } }