n,m=map(int,input().split())
hoge=list(map(int,input().split()))
hoge.sort()
ans=0
for i in range(n):
  if(hoge[i]<=m):
    ans+=1
    m-=hoge[i]
  else:
    break
if(m==0):
  print(ans)
else:
  if(sum(hoge)<m):
    print(n-1)
  else:
    print(ans)