N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
S = 0
ans = 0
for i in range(N):
  S += A[i]
  if S <= X:
    ans += 1
  else:
    break
if S > X:
  ans = N-1
print(ans)
