local n, x = io.read("*n", "*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
table.sort(a)
local cnt = 0
for i = 1, n do
  if i == n then
    if a[i] == x then
      cnt = cnt + 1
    end
  else
    if a[i] <= x then
      cnt = cnt + 1
      x = x - a[i]
    else
      break
    end
  end
end
print(cnt)
