N,x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a_sorted = sorted(a)
num =0
x_num = x
for i in range(N):
    if(x_num - a_sorted[i] > 0):
        x_num -= a_sorted[i]
        num += 1
    else:
        break
print(num)
