N,x = map(int,input().split())
a = list(input().split())
a = [int(i) for i in a]
a.sort()
for i in range(N,-1,-1):
    b = sum(a[0:i])
    if b<x and i != 0:
        res = i-1
        break
    elif b==x and i != 0:
        res = i
        break
    elif b< x and i==0:
        res = 0
    elif b== x and i == 0:
        res = 1
print(res)