n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
if x > sum(a):
    print(n-1)
    exit()
if x == sum(a):
    print(n)
    exit()
for i in range(n-1):
    a.pop(0)
    if x > sum(a):
        print(n-(i+1)-1)
        exit()
    elif x == sum(a):
        print(n-(i+1))
        exit()
    else:
        continue
print(0)