my$L=get; get; my$z=0; my@a; ++@a[$_]for get.words; for 1..@a {$_>$L or$L-=$_,$z++while @a[$_]--} say $z