from bisect import bisect_right

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
SUM = [a[0]]

for i in range(1, n):
    SUM.append(SUM[-1]+a[i])

if SUM[-1] < x:
    print(n-1)
else:
    print(bisect_right(x, SUM))