#K76947. Alternate String Transformation

    ID: 34755 Type: Default 1000ms 256MiB

Alternate String Transformation

Alternate String Transformation

In this problem, you are given a binary string S, and you need to determine the minimum number of operations required to convert S into an alternating binary string. An alternating binary string is one in which every two adjacent characters are different, i.e., (S_i \neq S_{i+1}). You can flip any character (change '0' to '1' or '1' to '0'). Your task is to calculate the minimum number of flips required to achieve this alternating pattern.

inputFormat

The input is read from standard input (stdin) and consists of a single line containing a binary string S. The string S is composed only of characters '0' and '1'.

outputFormat

Output a single integer to standard output (stdout), which represents the minimum number of operations required to convert S into an alternating binary string.## sample

010101
0