using System; using System.Linq; using System.Collections.Generic; using System.Text; using static System.Console; using static System.Math; class Program { static void Main(string[] args) { int L = ReadLineParseInt(); int N = ReadLineParseInt(); int[] W = ReadLine().Split(" ").Select(int.Parse).ToArray(); Array.Sort(W); int count = 0; for(int i = 0; i < W.Length; i++) { count += W[i]; if(count > L) { WriteLine(i); return; } } } static int ReadLineParseInt() => int.Parse(ReadLine()); }