using System; using System.IO; class Start{ static void Solve(){ long l;Inl(out l); long n;Inl(out n); long[] w=new long[n];Inl(ref w); Sort(ref w); long W=0; int i=0; while(i!=n&&W+w[i]<=l)W+=w[i++]; Outl(i); } static void Main(){ var sw=new StreamWriter(Console.OpenStandardOutput()){AutoFlush=false}; Console.SetOut(sw); Solve(); Console.Out.Flush(); } static void Inl(out long t){t=long.Parse(Console.ReadLine());} static void Inl(out string t){t=Console.ReadLine();} static void Inl(out char t){t=Console.ReadLine()[0];} static void Inl(out double t){t=double.Parse(Console.ReadLine());} static void Inl(ref T[] t){ string[] s=Console.ReadLine().Split(); Type type=typeof(T); int n=s.Length; if(type==LONG)for(int i=0;i(out T t,out U u){string[] s=Console.ReadLine().Split();In(out t,ref s,0);In(out u,ref s,1);} static void Inl(out T t,out U u,out V v){string[] s=Console.ReadLine().Split();In(out t,ref s,0);In(out u,ref s,1);In(out v,ref s,2);} static void Inl(out T t,out U u,out V v,out W w){string[] s=Console.ReadLine().Split();In(out t,ref s,0);In(out u,ref s,1);In(out v,ref s,2);In(out w,ref s,3);} static void Inl(out T t,out U u,out V v,out W w,out X x){string[] s=Console.ReadLine().Split();In(out t,ref s,0);In(out u,ref s,1);In(out v,ref s,2);In(out w,ref s,3);In(out x,ref s,4);} static void Inl(out T t,out U u,out V v,out W w,out X x,out Y y){string[] s=Console.ReadLine().Split();In(out t,ref s,0);In(out u,ref s,1);In(out v,ref s,2);In(out w,ref s,3);In(out x,ref s,4);In(out y,ref s,5);} static void Inl(out T t,out U u,out V v,out W w,out X x,out Y y,out Z z){string[] s=Console.ReadLine().Split();In(out t,ref s,0);In(out u,ref s,1);In(out v,ref s,2);In(out w,ref s,3);In(out x,ref s,4);In(out y,ref s,5);In(out z,ref s,6);} static void In(out T t,ref string[] s,int i){ Type type=typeof(T); if(type==LONG)t=(T)(object)long.Parse(s[i]); else if(type==STRING)t=(T)(object)s[i]; else if(type==CHAR)t=(T)(object)s[i][0]; else t=(T)(object)double.Parse(s[i]); } static Type LONG=typeof(long); static Type STRING=typeof(string); static Type CHAR=typeof(char); static void Out(T t){Console.Write(t);} static void Outl(T t){Console.WriteLine(t);} static void Out(double d,int n){string s=d.ToString("F"+n);Console.Write(s);} static void Outl(double d,int n){string s=d.ToString("F"+n);Console.WriteLine(s);} static void Swap(ref T a,ref T b){T c=a;a=b;b=c;} static void Sort(ref T[] t){Array.Sort(t);} static T Max(params T[] t)where T:IComparable{T max=t[0];for(int i=1;i(params T[] t)where T:IComparable{T max=t[0];for(int i=1;i0)max=t[i];return max;} }