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

candy_num.sort(reverse=True)

sum_want = 0
num_child = 0

for i in candy_num:
    sum_want += i
    num_child += 1
    if not sum_want <= x:
        break

if num_child == N:
    print(N-1)
else:
    print(num_child)