#K75867. Alternate Character String Transformation

    ID: 34515 Type: Default 1000ms 256MiB

Alternate Character String Transformation

Alternate Character String Transformation

Given a string s consisting solely of the characters 'A' and 'B', your task is to determine the minimum number of modifications required to turn the string into an alternating sequence. The alternating sequence can be either ABABAB… (starting with 'A') or BABABA… (starting with 'B').

For example, if s = "AAAA", one optimal solution is to change the second and fourth characters to 'B', resulting in "ABAB", which uses 2 modifications. If the string is already alternating, no changes are required.

The solution should be efficient even when the string becomes very large.

Note: If the input string is empty, output 0.

inputFormat

The input consists of a single line containing the string s (with only characters 'A' and 'B'). The string may be empty.

outputFormat

Output a single integer — the minimum number of changes required to transform the string into an alternating pattern.

## sample
AAAA
2