import numpy as np

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

if sum(A) == x:
  print(N)
elif sum(A) < x:
  print(N-1)
else:
  cum = np.cumsum(A)
  if cum[0] > x:
    print(0)
  else:
    k = np.where(cum <= x)[0]
    print(k+1)