func main()
	var L: int :: cui@input().toInt(&)
	var N: int :: cui@input().toInt(&)
	var ss: [][]char :: cui@input().split(" ")
	var W: []int :: #[N]int
	for i(0, N - 1)
		do W[i] :: ss[i].toInt(&)
	end for
	
	do W.sort()
	
	var sum: int
	for i(0, N - 1)
		do sum :+ W[i]
		if(sum > L)
			do cui@print("\{i}\n")
			ret
		end if
	end for
	do cui@print("\{N}\n")
end func