import numpy as np

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

A = np.array(input().split(), dtype = np.int64)

A.sort()

np.cumsum(A, out = A)

answer = (A <= x).sum()



if answer == N and A[-1] != x:

  answer -= 1

print(answer)

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from bisect import bisect_right

import itertools



N,X,*A = list(map(int,read().split()))



A.sort()

Acum = list(itertools.accumulate(A))



answer = bisect_right(Acum,X)

if answer == N:

    if Acum[-1] < X:

        answer -= 1

print(answer)
import numpy as np

N, x = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.int64)
A.sort()
np.cumsum(A, out=A)
answer = (A <= x).sum()
if answer == N and A[-1] != x:
    answer -= 1
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_right
import itertools

N, X, *A = list(map(int, read().split()))
A.sort()
Acum = list(itertools.accumulate(A))
answer = bisect_right(Acum, X)
if answer == N:
    if Acum[-1] < X:
        answer -= 1
print(answer)

-import numpy as np +import sys -N, x = list(map(int, input().split())) -A = np.array(input().split(), dtype=np.int64) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +from bisect import bisect_right +import itertools + +N, X, *A = list(map(int, read().split())) -np.cumsum(A, out=A) -answer = (A <= x).sum() -if answer == N and A[-1] != x: -    answer -= 1 +Acum = list(itertools.accumulate(A)) +answer = bisect_right(Acum, X) +if answer == N: +    if Acum[-1] < X: +        answer -= 1