# -*- coding:UTF-8 -*-

li = input().split()
k = int(li[1])
print(k)
del li[:2]
li.sort()
j = 0
t = 0
for i in li:
    k -= int(i)
    print(k)
    if k == 0:
        t += 1
        break
    elif k < 0:
        t += 1
        break
    else:
        t += 1
if not k == 0:
    t -= 1

print(t)
