n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        ans += 1
if x != 0:
    ans = max(0, ans - 1)
print(ans)
