N, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
l = [0]*N
for i in range(N):
  if X >= A[i]:
    X -= A[i]
    l[i] = A[i]
ans = 0
for i in range(N):
  if A[i] - l[i] == 0:
    ans += 1
if X != 0:
  ans -= 1
print(ans)