N, X = list(map(int, input().split()))
A = sorted(list(map(int, input().split())))
last_index = len(A) - 1
ret = 0
for i, a in enumerate(A):
    if a < X and i == last_index:
        ret = N - 1
    else:
        ret += 1
        X -= a
print(ret)