n,x=map(int, input().split())
l=sorted(list(map(int, input().split())))
ans=0
if x==sum(l):
  print(n)
elif x>sum(l):
  print(n-1)
else:
  for i in range(n):
    if x-l[i]>=0:
      ans+=1
    else:
      print(ans)
      exit()
  print(ans-1)    
 