Patriotic Ribbon
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Petrik has a ribbon divided into \(n\) equal parts, where each part is painted in one of two colors — blue or yellow. Petrik considers the ribbon to be patriotic if no two adjacent parts are painted in the same color.
In one hour, Petrik can choose any part and repaint it to the other color (from blue to yellow or vice versa). Help Petrik determine the minimum number of hours required to make the ribbon patriotic.
Input
The single line contains a string \(s\) consisting of the characters
B and Y.
The character B represents a blue part, and
Y represents a yellow part.
Output
In a single line, print a single integer — the minimum number of hours.
Constraints
\(1 \le |s| \le 10^5\), where \(|s|\) is the number of characters in the string \(s\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| BYB | 0 |
| Input (stdin) | Output (stdout) |
|---|---|
| YYBBB | 2 |
Notes
In the first example, Petrik doesn’t need to change anything — the given ribbon is already patriotic.
In the second example, Petrik can change the first and fourth parts
to form the ribbon BYBYB.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|