N,x=map(int,input().split())
a=list(map(int,input().split()))
b=sorted(a)
c=0
while True:
  if sum(a)==x:
    print(N)
    break
  elif b[c]<=x:
    x=x-b[c]
    c+=1
  else:
    if sum(a)<x:
      print(c-1)
    else:
      print(c)
    break
