There are two mines, each employing a group of miners. Mining coal is hard work, so the miners need food. Each time a food container is delivered to a mine, the miners produce some amount of coal. There are three types of containers: meat, fish, and bread.
Miners like variety in their food, and their work becomes more productive when there is variety. When a food container arrives at the mine, the miners consider the type of the new container and the previous two containers (or fewer, if fewer than three containers have arrived at that mine so far), and then:
If all containers under consideration are of the same type, the miners produce one unit of coal.
If there are two different types among the containers under consideration, the miners produce two units of coal.
If there are three different types among the containers under consideration, the miners produce three units of coal.
The types and the order in which the containers are sent are known in advance. You can decide which container is sent to which mine to maximize the amount of coal produced. Containers cannot be split; each container must be sent entirely to one mine.
It is not necessary for both mines to receive the same number of containers (for example, it is allowed to send all containers to one mine).
Your program will be given the sequence of container types. Write a program that determines the maximum total amount of coal that can be produced in both mines, by choosing which containers to send to mine and which to mine .
The first line contains an integer (1 \le n \le 100\,000), the number of containers.
The second line contains a string of uppercase letters, denoting the types of containers in the given order. Each letter is one of M (meat), F (fish), or B (bread).
Output one integer — the maximum total amount of coal that can be produced.
Example 1
Example 2