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

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

temp=x

ans=0

a.sort()

i=-1

while True:

    i+=1

    x-=a[i]

    if x<0:

        break

    ans+=1

    if ans==N:

        break

if sum(a)<temp:

    ans-=1

    

print(ans)

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

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

man=[0]*N

a.sort()

ans=0

for i in range(N):

    if a[i]<=x:

        x-=a[i]

        a[i]=0

        ans+=1

    else:

        break

if ans==N:

    if x!=0:

        ans-=1

if ans<0:

    ans=0

print(ans)

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
temp = x
ans = 0
a.sort()
i = -1
while True:
    i += 1
    x -= a[i]
    if x < 0:
        break
    ans += 1
    if ans == N:
        break
if sum(a) < temp:
    ans -= 1
print(ans)

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

-temp = x +man = [0] * N +a.sort() -a.sort() -i = -1 -while True: -    i += 1 -    x -= a[i] -    if x < 0: +for i in range(N): +    if a[i] <= x: +        x -= a[i] +        a[i] = 0 +        ans += 1 +    else: -    ans += 1 -    if ans == N: -        break -if sum(a) < temp: -    ans -= 1 +if ans == N: +    if x != 0: +        ans -= 1 +if ans < 0: +    ans = 0