n, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
num = 0
if sum(a) < x:
    print(n-1)
elif a[-1] > x:
    print(0)
else:
    while x > 0:
        x = x - a.pop()
        num += 1
    print(num)