$l=<>;<>;($l-=$_)<0?0:$c++for sort{$a<=>$b}<>=~/\S+/g;print$c