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

A.sort()
S = 0
count = 0

for i in range(N):
  S += A[i]
  
if S < x:
  print(N-1)
  exit()
else:
  for i in range(N):
    b = x - A[i]
    if b > 0:
      count += 1
      x -= A[i]
    elif b == 0:
      count += 1
      exit()
    else:
      exit()
  print(count)