401824: GYM100534 G Coin Game

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Coin Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Alice and Bob are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they always find the best strategy, and that's why they feel bored again and again. They just invented a new game, as they usually did. They are playing with coins. They have a row of $1 and $2 coins. They want to change this row so that all $1's are grouped together and all $2's are grouped together. They are just allowed to swap two neighbor coins. Using the best strategy what is the minimum number of swaps required to do this task?

Input

Each test case is a line with a string composed of 1 and 2. (1 ≤ length of the input string ≤ 25000)

Output

Print the minimum number of swaps required to do this task.

ExamplesInput
221212
Output
3

加入题单

算法标签: