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

from itertools import accumulate
Acumsum = list(accumulate(A))

i=0
while i<N:
  if Acumsum[i] < x:
    i+=1
  else:
    break

if i==N:
  print(N-1)
elif i==N-1:
  if Acumsum[-1]==x:
    print(N)
  else:
    print(N-1) 
else:
  print(i)