N,x=map(int, raw_input().split() )
A=map(int, raw_input().split() )

A.sort()

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

print ans