n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=0
if a[0]>x:
    print(0)
    exit()
if sum(a)<x:
    print(n-1)
    exit()
for i in range(n):
    if s+a[i]<x:
        s+=a[i]
    else:
        print(i+1)
        exit()