n, x = map(int, input().split())
a = list(map(int, input().split()))
oka = sorted(a)
total=0
ans=0
for i in range(n):
    total += oka[i]
    if total >= x:
        ans=i+1
        break
if oka[0]>x:
    ans=0
if total <x:
    ans= n 
print(ans)
