#!/bin/ruby input = gets.chomp.split(' ') N = input[0].to_i M = input[1].to_i c = gets.chomp.split(' ').sort sum = 0 box = 0 c.each { |num| sum += num.to_i box += 1 if sum > M break end if sum === M box += 1 break end } puts box