using System; using System.Linq; namespace Suuji_no_Block_CS { class Program { static int Solve(int L, int[] W) { int ret=0; foreach(int x in W) { L -= x; if(L < 0) { break; } ret++; } return ret; } static void Main(string[] args) { int L = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); int[] W = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).OrderBy(value => value).ToArray(); Console.WriteLine(Solve(L, W)); } } }