#Elections are in progress!

#Given an array of the numbers of votes given to each of the candidates so far, 
#and an integer k equal to the number of voters who haven't cast their vote yet, 
#find the number of candidates who still have a chance to win the election.

#The winner of the election must secure strictly more votes than any other candidate. 
#If two or more candidates receive the same (maximum) number of votes, assume there is no winner at all.

#Example

#For votes = [2, 3, 5, 2] and k = 3, the output should be
#electionsWinners(votes, k) = 2.

#The first candidate got 2 votes. 
#Even if all of the remaining 3 candidates vote for him, he will still have only 5 votes, 
#i.e. the same number as the third candidate, so there will be no winner.
#The second candidate can win if all the remaining candidates vote for him (3 + 3 = 6 > 5).
#The third candidate can win even if none of the remaining candidates vote for him. 
#For example, if each of the remaining voters cast their votes for each of his opponents, 
#he will still be the winner (the votes array will thus be [3, 4, 5, 3]).
#The last candidate can't win no matter what (for the same reason as the first candidate).
#Thus, only 2 candidates can win (the second and the third), which is the answer.

def electionsWinners(votes, k):

	maximo = max(votes)

	long = len(votes)

	ganar = 0
	maximos = 0
	#una = 0
	for i in range(long):
		#if votes[i]!=maximo:
		if (votes[i] + k) > maximo:
			#votes[i] += k
			ganar += 1
	#		una = 1
		if votes[i] == maximo:
			maximos += 1
		#else:
		#	ganar += 1
		#	maximos += 1
	# If the maximum number is tied ganar=0
	#if maximos > 1 & una ==0:
	#	print(maximos, una)
	#	return 0
	#else:
	#print('Maximos :',maximos,'Ganar: ',ganar)
	# Maximos counts the number of initial maximum numbers
	# If there was no winner and there was more than 1 initial maximum then there was no winner at all
	if ((maximos > 1) & (ganar==0)): 
		#print("Entro 0")
		return 0
	elif ((maximos == 1) & (ganar ==0)):
		#print("Entro 1")
		return 1
	else: 
		#print("Entro 2")
		return ganar


