
from itertools import accumulate


def LI():
    return list(map(int, input().split()))


N, x = LI()
a = LI()
a.sort()
Asum = list(accumulate(a))
ans = 0
if Asum[N-1] == x:
    ans = N
elif Asum[N-1] < x:
    ans = N-1
elif Asum[0] > x:
    ans = 0
else:
    for i in range(N):
        if Asum[i] <= x:
            ans += 1
        else:
            if Asum[i-1] != x:
                ans -= 1
            break
print(ans)
