import bisect


n, x = map(int, input().split())
a = list(sorted(map(int, input().split())))
acc = [0 for i in range(n)]
acc[0] = a[0]
for i in range(1, n):
    acc[i] += a[i - 1] + a[i]
index = bisect.bisect_left(acc, x)
print(index)