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

    