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

A.sort()
Sum = sum(A)
if x >= Sum:
  print(N)
  exit()

ans = 0
for i in range(N):
  if x >= A[i]:
    ans += 1
    x -= A[i]
  else:
    print(ans)
    break
else:
  print(ans)