cswork / OAOpen practice workspace

AmazonOA #366

Find Minimum Inefficienty

Estimated EasyJudge-ready

Topics (AI-labelled)GreedyStrings

Replace each ? independently with 0 or 1 to minimize the number of adjacent character pairs that differ. Fixed 0/1 characters cannot be changed.

Input

One line containing a string made only of 0, 1 and ?. The complete original bounds are 1≤length≤100000.

Output

Output a single integer, the answer.

Example 1

Input:

??011??0

Output:

2

Example 2

Input:

00?10??1?

Output:

3

Example 3

Input:

???

Output:

0

Example notes

The answers are 2, 3 and 0. The explanation of the original second example gives 10 characters, which does not match the 9-character input; a valid optimal filling, 001101111, has length 9 and 3 changes.

Editorial

Loading solution…