import sys
input=sys.stdin.readline
from bisect import bisect_right
import itertools

N,X= map(int,input().split())
A=list(map(int,input().split()))

A.sort()
Acum = list(itertools.accumulate(A))
print(Acum)
answer = bisect_right(Acum,X)
if answer == N:
    if Acum[-1] < X:
        answer -= 1
print(answer)
