n,x = gets.split.map(&:to_i)
aa = gets.split.map(&:to_i).sort

if aa.inject(:+) == x
  puts n
  exit
end

ans = 0
aa.each do |a|
  if x >= a
    ans += 1
    x -= a
  else
    break
  end
end

puts ans