#K83477. Maximum Different Color Pairs

    ID: 36206 Type: Default 1000ms 256MiB

Maximum Different Color Pairs

Maximum Different Color Pairs

Given a string S composed of the characters R, G, and B, determine the maximum number of consecutive pairs with different colors that can be achieved by selecting a subsequence of stones from left to right. In other words, starting with the first stone, each time you encounter a stone whose color is different from the previously chosen stone, you count one pair.

Formally, if the chosen subsequence is \(a_1, a_2, \ldots, a_k\), the answer is given by \[ \sum_{i=2}^{k} I(a_i \neq a_{i-1}) \] where \(I(\cdot)\) is the indicator function that equals 1 when the condition is true and 0 otherwise.

For example, if S = "RGBGR", one optimal subsequence is "RGBGR" which yields 4 pairs of consecutive stones with different colors.

inputFormat

The input consists of a single line containing a string S (with no spaces) composed exclusively of the letters R, G, and B.

Input is read from standard input (stdin).

outputFormat

Output a single integer, the maximum number of pairs of consecutive stones in any subsequence of S that have different colors. The output should be written to standard output (stdout).

## sample
RGBGR
4