N, x = io.read("*n", "*n")

a = {}

for v = 1, N do
  a[v] = io.read("*n")
end

table.sort(a)

ans = 0

for v = 1, N do
  x = x - a[v]
  if x < 0 then
    break
  end
  ans = ans + 1
end

if x > 0 then
  ans = ans - 1
end

print(ans)
