a = input().split()
a = [int(i) for i in a]
b = input().split()
b = [int(i) for i in b]
b = sorted(b)
output = 0
end = False

for i in range(len(b)-  1):
	if a[1] - b[i] > 0:
		a[1] += -b[i]
		output += 1
	elif(a[1] - b[i] == 0):
		output += 1
		end = True
		break
	else:
		end = True
		break
		
if end == False:
	if a[1] - b[-1] < 0:
		output -= 1
	elif a[1] - b[-1] > 0:
		output -= 1
	else:
		output += 1
		 
print(output)