import itertools
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = list(itertools.accumulate(a))
cnt=0
for i in range(n):
    if i==n-1 and a[-1]!=x:
        pass
    elif a[i]<=x:
        cnt+=1
        if a[i]==x:
            break
print(cnt)