6.1 Plants in the Garden
(RankList for this Question)
Score: 30pts
Time Limit: 3.00 sec
There are n plants in a garden(planted in a pot), in a row, each of them can be of type A, B or C. Count the minimum number of pots to remove from the garden so that any two neighboring plants are of different types. Plants in a row are considered neighboring if there are no other pots between them.

1 ≤ n ≤ 50

Input Format
The first line contains integer n (1 ≤ n ≤ 50) — the number of pots on the table.
The next line contains string s, which represents the type of the plants. We'll consider the pots in the row numbered from 1 to n from left to right.

Output Format
Print a single integer — the answer to the problem.

Example 1


In the sample test case, we get a string of 3 pots as an input, and to fulfill our condition of removing the minimum number of pots so as to have different types of neighboring plants, we have to remove either the first ‘A’ or the second ‘A’ pot and hence the answer is 1.

Log In to solve the Question