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
  for i in a:
    temp=x-i
    if temp>=0:
      flag=True
      x-=i
      ans+=1
  if flag==False:
    print(0)
    exit()
  print(ans if x==0 else ans-1)
