eolymp
bolt
Try our new interface for solving problems

Balls

In a computer game, a player puts in a line of balls of different colors. When formed by a continuous chain of three or more balls of one color, it is removed from the line. All the balls at the same time shift to each other, and the situation could happen again.

Write a program that in this situation, determine how many balls will now be destroyed. Of course, continuous strings of three or more same color balls in the initial time may be no more than one.

Input

iven the number of balls in the chain (not more 1000) and the color of the balls (from 0 to 9, each color corresponds to a whole number).

Output

You want to display the number of balls that will be destroyed.

Time limit 1 second
Memory limit 64 MiB
Input example #1
5 1 3 3 3 2
Output example #1
3
Source Stage II Ukrainian School Olympiad 2011-2012, Berdichev