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:
        if i == last_index and X > 0:
            continue
        ret += 1
        X -= a
print(ret)