n, m = gets.split.map(&:to_i) cs = gets.split.map(&:to_i).sort ans = 0 cs.each do |c| t = [c, m].min m -= t c -= t if c == 0 ans += 1 end if m == 0 break end end puts ans