N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
if sum(A) < x:
    print(N - 1)
    exit()
A = [1] + A
ans = 0
while A[-1] <= x:
    x -= A[-1]
    A.pop()
    ans += 1
print(ans)

396ecf73109405ebbb4a45d601b1808ec67edc10
<mask token>

<mask token>
A.sort(reverse=True)
if sum(A) < x:
    print(N - 1)
    exit()
<mask token>
while A[-1] <= x:
    x -= A[-1]
    A.pop()
    ans += 1
print(ans)

N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
if sum(A) < x:
    print(N - 1)
    exit()
A = [1] + A
ans = 0
while A[-1] <= x:
    x -= A[-1]
    A.pop()
    ans += 1
print(ans)
