N,x = map(int,input().split())
a_list = list(map(int,input().split()))
a_list_sort = sorted(a_list)
#print(a_list)
#print(a_list_sort)
count = 0

if sum(a_list) <= x :
	count = N-1
else:
	for i in range(N):
		if sum(a_list_sort[:i+1]) <= x:
			continue	
		else:
			count = i
			break
print(count)