import bisect
import numpy
N,x=(int(i) for i in input().split())
lst=[int(i) for i in input().split()]
lst.sort()
res=numpy.cumsum(lst)
S=sum(lst)
if S==x:
  print(N)
else:
  num=bisect.bisect_right(lst,x)
  if num==N:
    print(N-1)
  else:
    print(num)