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

a.sort()

count = 0

for v in a:
    if v <= x and x >= 0:
        count +=1
        x -= v
        
if x != 0:
    count = count - 1

print(count)
