n,x=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
a.sort()
ans=0
for i in range(n):
    x-=a[i]
    if x<0:
        ans=i
        break
if x>=0:
    ans=n
print(ans)