N, x = map(int, input().split())
fav = sorted(map(int, input().split()))
oura=[int()]*N

oura[0] = fav[0]
for i in range(len(fav)-1):
    oura[i+1] = oura[i] + fav[i+1]

print (oura)

sai = 0
for j in range(len(oura)):
    if oura[j] > x:
        sai = j
        break
    elif j != N-1:
        continue
    elif oura[N-1] == x:
        sai = N
    else:
        sai = N-1

print (sai)
