N,x=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)==x:
  print(N)
  exit()
else:
  a.sort()
  ans=0
  flag=False
  i=0
  while i<N:
    if x-a[i]>=0:
      flag=True
      x=x-a[i]
      ans+=1
    i+=1
if flag==False:
  print(0)
  exit()
print(ans if x==0 else ans-1)
