N, x = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
b = 0
c = 0
if sum(a)<x:
    b -= 1

for i in range(N):
    if c <= x:
        c +=a[i]
        b +=1
    else:
        break
print(b)