eval'L,N,*W='+$<.read.split*?, s=0 (0..N).any?{|i|s+=W.sort[i];i+=1;s>L&&s=i} p s