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

a.sort()
count = 0

for i in a:
    if x >= i:
        x -= i
        count += 1
    else:
        break

if x != 0:
    count -= 1

print(count)