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