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

d.sort()
happy = 0

for i in range(N):
    x = x - d[i]
    if i == len(d)-1:
        break
    if x < 0:
        break
    else:
        happy += 1

print(happy)