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

a_list = list(map(int, input().split()))
a_list.sort()
give = 0
count = 0

for num in a_list:
    give += num
    if give > x:
        break
    count += 1

print(count)
