N,x = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
i = 0
tmp =0
while True:
    if i == len(A):
        print(i)
        exit()
    else:
        tmp += A[i]
        if tmp > x or i == len(A):
            print(i)
            exit()
        else:
            i += 1
