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

ans = 0
for i in range(n):
    if x - a[i] >= 0:
        ans += 1
        x = x - a[i]
    else:
        break
if x > 0 and ans != 0:
    ans -= 1

print(ans)
