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

li.sort()

child = 0
candy = 0
for a in li:
    if candy + a > x:
        continue
    candy += a
    child += 1
    if candy == x:
        break
else:
    child -= 1

print(child)