n, x = map(int, input().split())
l = sorted(list(map(int, input().split())))
kids = 0
ans = 0
for i in range(n):
    print(kids, ans)
    kids += l[i]
    if kids <= x:
        ans += 1
    else:
        break

if sum(l) >= x:
    print(ans)
else:
    print(ans - 1)