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

a.sort()

ans = 0
i = 0

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

if x != 0:
    ans -= 1

print(ans)
