using System; using System.Collections.Generic; using System.Linq; namespace lecture { class MainClass { public static void Main(string[] args) { int L = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); int[] W = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray(); int kazu = 0; int count = 0; Array.Sort(W); for (int i = 0; i < N; i++) { if (L <= kazu) { count--; break; } kazu += W[i]; count++; } Console.WriteLine(count); } } }