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

a.sort()
x_tmp = x
delighted_num = 0

for ax in a:
    if x_tmp >= ax:
        x_tmp = x_tmp - ax
        delighted_num += 1
if x_tmp > 0 and delighted_num > 0:
    delighted_num -= 1
print(delighted_num)
