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

cnt = 0
for i in a:
    if x >= i:
        cnt = cnt + 1
    else:
        break
    x = x - i

if x < 0:
    cnt = cnt - 1
print (cnt)
