cswork / OAOpen practice workspace

Akuna CapitalOA #5

Binary Circuit

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyStrings

Move all 1s in the binary string to the end. One operation picks a 1 and moves it right to the farthest position, just before the next 1 or at the end of the string; the cost of the operation is 1 plus the number of positions moved. Choose the order of operations to maximize the total cost. If the string is already 0...01...1, the cost is 0.

Input

The input is one line with the binary string s. The original range 1≤|s|≤100000 is used.

Output

Output the maximum total cost needed to complete the grouping.

Example 1

Input:

110100

Output:

13

Example 2

Input:

10100

Output:

8

Example 3

Input:

000111

Output:

0

Editorial

Loading solution…