class Calc0156 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n, @m = args.shift.map(&:to_i) @cs = args.shift.map(&:to_i) end def run t = 0 @cs.sort.each_with_index do |c, i| t += c return i if t > @m end @n end end puts Calc0156.new(STDIN.readlines).run if __FILE__ == $0