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

count = 0
array = sorted(array, reverse=True)
for i in range(n):
    x = x - array[i]
    if x >= 0:
        count += 1
    else:
        break
print(count)