n,x=map(int,input().split())
l=sorted(list(map(int,input().split())))

num=0
c=0

if l[0]==x:
  print(1)
  exit()
else:
  for i in range(n):
    if num+l[i]>x:
      print(c)
      exit()
    else:
      num+=l[i]
      c+=1
      
print(c)