using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicoder5 { class Program { static void Main(string[] args) { int l = int.Parse(Console.ReadLine()); int n = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(' '); int[] w = new int[s.Length]; for (int i = 0; i < n; i++) { w[i] = int.Parse(s[i]); } Array.Sort(w); int sum = 0; int cnt = 0; for (int i = 0; i < n; i++) { sum += w[i]; if (l >= sum) { cnt++; } else { break; } } Console.WriteLine(cnt); } } }