N,x=map(int,input().split())

a=list(map(int,input().split()))

a.sort(reverse=True)

if x>sum(a):
    print(N-1)
elif x==sum(a):
    print(N)
else:
    ans=0
    for i in range(N):
        if x<=0:
            break
        elif x>=a[i]:
            ans+=1
            x-a[i]
    print(ans)