n,x = map(int,input().split())
li = list(map(int,input().split()))
list.sort(li)
total = 0
num = 0
for i in range(n):
    if total + li[i] >= x:
        num = i + 1
        break
    elif i == n - 1:
        num = i + 1
    else:
        total += li[i]
print(num)
