N,x = map(int,input().split())
# a=[int(input()) for i in range(4)]
a = list(map(int,input().split()))
count = 0
#昇順に並べ替える
sort_a = sorted(a)

for i in range(len(N)):
    if x >= sort_a[i]:
        count += 1
        x -= sort_a[i]
        print(x)
        continue
    break
print(count)
