import sys
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
if sum(a) == x:
    print(n)
    sys.exit()
if a[0] > x:
    print(0)
    sys.exit()
for i in range(len(a)):
    if sum(a[0:i]) >= x:
        print(i)
        sys.exit()
print(n-1)

