nx = [int(i) for i in input().split()]
n = nx[0]
x = nx[1]
a = [int(i) for i in input().split()]
b =list(sorted(a))
s = 0
ans = 0
for i in range(n+1):
    if sum(b[:i])<=x:
        s = sum(b[:i])
        ans = i
print(ans)
