Time limit
2s
Memory limit
128 MB
You are given a binary string S. In one move, choose one or more consecutive characters of S and flip all of them: 0 becomes 1, and 1 becomes 0.
Your goal is to make every character in the string equal.
For instance, let S = 0001100.
1110011.1111111, so two moves are enough.However, if you flip only the 4th through 5th characters from the start, the string becomes 0000000, so one move is enough.
Given S, find the minimum number of moves needed.
The first line contains a binary string S. The length of S is less than 1,000,000.
Print the minimum number of moves needed to make every character equal.