#C6211. Minimum Changes to Avoid Repeating Adjacent Characters
Minimum Changes to Avoid Repeating Adjacent Characters
Minimum Changes to Avoid Repeating Adjacent Characters
Given a string s consisting of lowercase English letters, your task is to determine the minimum number of character modifications required so that no two adjacent characters are identical.
Formally, for a string \( s \) of length \( n \), you need to ensure that \( s_i \neq s_{i+1} \) for every \( 1 \leq i < n \). In one modification, you can change any single character to any other lowercase letter.
For example, given the string "aab", changing the second 'a' to any other letter (say, 'c') will result in "acb" which satisfies the condition. Therefore, the answer is 1.
inputFormat
The input consists of a single line containing a non-empty string of lowercase alphabets.
outputFormat
Output a single integer on a new line, representing the minimum number of modifications needed so that no two adjacent characters in the string are the same.## sample
aab
1