#C8520. Minimum Replacements to Avoid Consecutive Duplicates

    ID: 52512 Type: Default 1000ms 256MiB

Minimum Replacements to Avoid Consecutive Duplicates

Minimum Replacements to Avoid Consecutive Duplicates

In this problem, you are given a string S consisting exclusively of the characters 'a', 'b', and 'c'. Your task is to compute the minimum number of replacements needed so that no two adjacent characters in the string are the same. Formally, for a string S of length n, you need to modify it such that for every index i (1 ≤ i < n), (S_i \neq S_{i+1}). A replacement operation allows you to change any character to either 'a', 'b', or 'c'. The goal is to achieve this with the minimum number of operations. This problem tests your ability to iterate through a string and count necessary modifications efficiently.

inputFormat

The input consists of a single line containing the string S. The string contains only the characters 'a', 'b', and 'c'.

outputFormat

Output a single integer representing the minimum number of replacements required to ensure that no two adjacent characters are the same.## sample

aab
1