N, x = map(int, input().split())

childlen = []
for part in input().split():
    childlen.append(int(part))

childlen.sort()
#print(childlen)

happy = 0
for n in range(len(childlen)):
    #print(child, x)
    child = childlen[n]

    if child <= x:
        x -= child
        happy += 1
    else:
        break

if x != 0:
    happy -= 1

print(happy)