n, x = input().split(" ")
a = input().split(" ")

n, x = int(n), int(x)
a = sorted([int(i) for i in a])

s = x
ret = 0
for i in a:
    if s >= i:
        ret += 1
        s -= i
        n -= 1

if ret and s:
    ret -= 1

print(ret)

