n,x=map(int,raw_input().split())
a=(map(int,raw_input().split()))

a.sort()
count=0
for i in range(n):
    x-=a[i]
    if x < 0:
        break
    count+=1

if x == 0:
    print(n)
elif x > 0:
    print(n-1)
else:
    print(count)

