N,x = map(int,input().split())
A = list(map(int,input().split()))
answer = 0
while x > 0  :
    A = sorted(A)
    if x < A[0] :
        break
    x = x - A[-1]
    answer += 1
    A.pop(-1)
    if len(A) == 0 :
        break
print(answer)

