In a computer game, the player arranges balls of different colors in a line. When a continuous chain of three or more balls of the same color is formed, it is removed from the line. All the remaining balls are then shifted towards each other, and this process can repeat.
Write a program to determine how many balls will be destroyed in this situation. Initially, there may be at most one continuous chain of three or more same-colored balls.
The number of balls in the chain (no more than ) and the colors of the balls (from to , with each color corresponding to its integer).
Print the number of balls that will be destroyed.
Example 1