a, b = map(int, input().split())
child = sorted(list(map(int, input().split())))
count = 0
print(child)

for i in range(a - 1):
    if b >= child[i]:
        b -= i
        count += 1
if b == child[-1]:
        count += 1

print(count)