using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int L = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); int count = 0; string[] strW = Console.ReadLine().Split(' '); int[] W = new int[N]; for (int i = 0; i < N; i++) { W[i] = int.Parse(strW[i]); } Array.Sort(W); while (L > 0) { L = L - W[count]; if (count < N) { if (L > 0) { count++; } } } Console.Write(count); } } }