import std.stdio; void main(){ auto cin = new Cin(); auto L = cin.line()[0]; auto N = cin.line()[0]; auto W = cin.line(); W.sort(); size_t i,j = 0; foreach( w ; W ){ i += 1; j += w; if( j > L ) break; } writeln( i ); //possible.writeln(); } auto solve(){ } unittest{ } import std.stdio,std.conv,std.string; import std.algorithm,std.array; class Cin { T[] line( T = size_t , string token = " " )( size_t m = 1 ){ T[] arr = []; foreach( i ; 0..m ){ arr ~= this.read!T(); } return arr; } T[][] rect( T = size_t , string token = " " )( size_t m = 1 ){ T[][] arr = new T[][](m); foreach( i ; 0..m ){ arr[i] = this.read!T(token); } return arr; } private T[] read( T = size_t )( string token = " " ){ T[] arr; foreach( elm ; readln().chomp().split(token) ){ arr ~= elm.to!T(); } return arr; } } class Tree( T = size_t ){ size_t[T][T] joint; void tie( T x , T y ){ } }