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
    else:
        break
if ret and s != 0:
    ret -= 1

print(ret)
