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

a.sort()
tmp = a[0]
cnt = 0
for i in range(1,n):
    #print(cnt,tmp)
    if tmp<=x:
        cnt += 1
        tmp += a[i]
    else:
        break
    
print(cnt)