N, X = list(map(int, input().split()))

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

a = sorted(a)



ans = 0

ttl = sum(a)



if ttl < X:

    ans = N - 1

elif ttl == X:

    ans = N

else:

    s = 0

    for ax in a:

        if s + ax <= X:

            s += ax

            ans += 1

        else:

            break

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

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

a = list(sorted(a))



X = x

ans = 0

for i, aa in enumerate(a, 0):

    if X >= aa:

        if i == N - 1:

            if X == aa:

                ans += 1

        else:

            X -= aa

            ans += 1

    else:

        break

print(ans)

N, X = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
ttl = sum(a)
if ttl < X:
    ans = N - 1
elif ttl == X:
    ans = N
else:
    s = 0
    for ax in a:
        if s + ax <= X:
            s += ax
            ans += 1
        else:
            break
print(ans)

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a = list(sorted(a))
X = x
ans = 0
for i, aa in enumerate(a, 0):
    if X >= aa:
        if i == N - 1:
            if X == aa:
                ans += 1
        else:
            X -= aa
            ans += 1
    else:
        break
print(ans)

-N, X = list(map(int, input().split())) +N, x = list(map(int, input().split())) -a = sorted(a) +a = list(sorted(a)) +X = x -ttl = sum(a) -if ttl < X: -    ans = N - 1 -elif ttl == X: -    ans = N -else: -    s = 0 -    for ax in a: -        if s + ax <= X: -            s += ax +for i, aa in enumerate(a, 0): +    if X >= aa: +        if i == N - 1: +            if X == aa: +                ans += 1 +        else: +            X -= aa -        else: -            break +    else: +        break