
import bisect


n, x = map(int, input().split())
a = list(sorted(map(int, input().split())))
if x == sum(x):
    print(n)
else:
    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_right(acc, x)
    if index == n:
        print(index - 1)
