import re
n, k = map(int, input().split(' '))
ai = list(map(int, input().split(' ')))
ai.sort()
total_sweet=0
result = 0
for ele in ai:
    total_sweet = total_sweet + ele
    if total_sweet > k:
        break
    result += 1
print(result)