Question and Answer from L4-M1
def soln(ingredients, n):
ones = ingredients.count('1')
twos = ingredients.count('2')
threes = ingredients.count('3')
if ones != twos or twos != threes or ones == 0:
return 0
if ones == 1 and twos == 1 and threes == 1:
pos1 = ingredients.index('1')
pos2 = ingredients.index('2')
pos3 = ingredients.index('3')
return 1 if pos1 < pos2 < pos3 else 0
return 0
print(soln(input().strip(), int(input())))