n, x = (int(i) for i in input().split(' '))
a = sorted([int(i) for i in input().split(' ')])

sum = 0;
ch = 0

for i in range(n):
    if sum == x:
        break
    
    sum += a[i]
    
    if sum  <= x:
        ch += 1

if sum != x:
    if ch:
        ch -= 1

print(ch)
        


