N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
p = sum(A)
if (x == p):
  print(N)
elif (x > p):
  print(N-1)
else:
  k = 0
  i = 0
  for i in range(N):
    if (x - A[i] >= 0):
      x -= A[i]
      k += 1
      i += 1
    else:
      break
print(k)