Given a string S consisting of N letters a and b. In one move you can replace one letter by the other (a by b or b by a).
Write a function solution that given such a string S, returns the minimum number of moves required to obtain a string containing no instances of three identical consecutive letters.
Example 1
Inputbaaaaa
Output: 1
Explanation: The string without three identical consecutive letters which can be obtained is one move is "baabaa".
Example 2
Inputbaaabbaabbba
Output: 1
Explanation: The string without three identical consecutive letters which can be obtained is one move is "baabaa"
Example 3
Inputbaabab
Output: 0
Assumptions:
N is an integer within the range [0, ..200,000];
String S consists of only characters a and b.