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

happy=0
a.sort()

for i in range(N):
    
    if a[i] > x:
        break

    else:
        x=x-a[i]
        happy=happy+1

print(happy)
