N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
if sum(a)<x:
  print(N-1)
else:
  ans=0
  d=[0]*N
  for i in range(N):
    if x>=a[i]:
      x-=a[i]
      d[i]=1
  ans=d.count(1)
  if x>0:
    print(max(ans-1,0))
  else:
    print(ans)

