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

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

ans = 0

if x<min(a):

    ans = 0

elif x>sum(a):

    ans = n-1

else:

    for i in range(1,n+1):

        if x>=sum(a[:i]):

            ans+=1

        else:

            break        

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

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

ans = 0

for i in a:

    if x>=i:

        ans+=1

        x-=i

print((ans-1 if ans==n and x>0 else ans))
n, x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
if x < min(a):
    ans = 0
elif x > sum(a):
    ans = n - 1
else:
    for i in range(1, n + 1):
        if x >= sum(a[:i]):
            ans += 1
        else:
            break
print(ans)

n, x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
for i in a:
    if x >= i:
        ans += 1
        x -= i
print((ans - 1 if ans == n and x > 0 else ans))

-if x < min(a): -    ans = 0 -elif x > sum(a): -    ans = n - 1 -else: -    for i in range(1, n + 1): -        if x >= sum(a[:i]): -            ans += 1 -        else: -            break -print(ans) +for i in a: +    if x >= i: +        ans += 1 +        x -= i +print((ans - 1 if ans == n and x > 0 else ans))