N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
max = 0
for i in range(1, N + 1):
  if sum(a[:i]) <= x:
    max = i
if sum(a[:N + 1]) <= x:
  print(N - 1)
else:
  print(max)