#22
N,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

if sum(a) ==x:
    print(N)
else:
    for i in range(N):
        if sum(a[0:i+1]) >x:
            print(i)
            break
    