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):
    sum += a[i]
    if sum > x:
        break;
    else:
        ch += 1
    if sum == x:
        break

if sum != x and ch != 0:
    ch -= 1
    
print(ch)
        


