using System; using System.Collections.Generic; using System.Linq; class MainClass { public static void Main(string[] args) { long x = 0; long i = 0; string stdin = Console.ReadLine(); long L = long.Parse(stdin); stdin = Console.ReadLine(); long N = long.Parse(stdin); stdin = Console.ReadLine(); string[] c = stdin.Split(' '); long[] w = new long[N]; for(i = 0; i < N; i++){ w[i] = long.Parse(c[i]); } Array.Sort(w); i = 0; while((x <= L) && i < N){ x += w[i]; i++; } Console.WriteLine(i); } }