temp = input().rstrip().split(" ")
N = int(temp[0])
X = int(temp[1])
list = input().rstrip().split(" ")
list.sort()
print(list)
c = 0
for i in range(N):
    X = X - int(list[i])
    if X >= 0:
       c += 1
    else:
        break
if X <= 0:
    print(c)
elif X > 0:
    print(c-1)