n, x = map(int, input().split())
a = list(map(int, input().split()))

l = sorted(a)
for i in range(n):
    x -= l[i]
    if x < 0:
        print(i)
        break
if x == 0:
    print(n)
else:
    print(n - 1)