# your code goes here
N,M=(int(i) for i in input().split())
C=[int(i) for i in input().split()]
C.sort()
i=0
S=0
while S<M:
    S+=C[i]
    i+=1
if S==M:
    print(i)
else:
    print(i-1)