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