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

A.sort()

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