#K60397. Make a Beautiful String
Make a Beautiful String
Make a Beautiful String
You are given a string s
. Your task is to compute the minimum number of character replacements required to transform the string into a "beautiful" string, where a beautiful string is defined as one in which no two consecutive characters are the same.
Formally, given a string \(s\), determine the smallest number of positions you need to change so that for every \(i\) (\(1 \leq i < |s|\)), \(s_i \neq s_{i+1}\).
Example:
Input: aabb Output: 2
In the example above, we can change the string "aabb" by replacing one of the consecutive duplicate characters to obtain a string like "abab", which meets the conditions.
inputFormat
The input consists of a single line containing the string s
.
outputFormat
Output a single integer representing the minimum number of replacements needed to transform the given string into a beautiful string.
## sampleaabb
2