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

ss = list(map(int, input().split(' ')))
    
r = x
count = 0    
for s in sorted(ss):
    if r - s < 0:
        break
    else:
        r -= s
        count += 1
if r > 0 and count > 0:
    count -= 1
print(count)        
    
