n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
if sum(l) <= x:
    print(n)
else:
    for i in range(n):
        if x <= l[i]:
            break
        x -= l[i]
    print(i)