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

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

if sum(a)<x:

    a.sort(reverse=True)

else:

    a.sort()

c=0

for t in a:

    x-=t

    if x<0:break

    c+=1

if x>0:

    print((c-1))

else:

    print(c)
n,x,*a=list(map(int,open(0).read().split()))

a.sort()

if sum(a)<x:a=a[::-1]

c=0

for t in a:

  x-=t

  if x<0:break

  c+=1

print((c-(x>0)))
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
if sum(a) < x:
    a.sort(reverse=True)
else:
    a.sort()
c = 0
for t in a:
    x -= t
    if x < 0:
        break
    c += 1
if x > 0:
    print((c - 1))
else:
    print(c)

n, x, *a = list(map(int, open(0).read().split()))
a.sort()
if sum(a) < x:
    a = a[::-1]
c = 0
for t in a:
    x -= t
    if x < 0:
        break
    c += 1
print((c - (x > 0)))

-n, x = list(map(int, input().split())) -a = list(map(int, input().split())) +n, x, *a = list(map(int, open(0).read().split())) +a.sort() -    a.sort(reverse=True) -else: -    a.sort() +    a = a[::-1] -if x > 0: -    print((c - 1)) -else: -    print(c) +print((c - (x > 0)))