← 返回 akunacapital 的题目列表Minimum Cost to Segregate Binary String
类型:online_judge
Given a binary string s consisting only of '0' and '1'.
Move '1' characters to the right so that all '0' characters appear before all '1' characters, resulting in:
000...0111...1
Moving a '1' right across one adjacent '0' costs 1. Return the minimum total cost required to segregate the string.
Input Format
One line containing the string s.
Output Format
Print one integer: the minimum total movement cost.
Example
Input:
01010
Output:
3
The first '1' crosses two zeros, and the second '1' crosses one zero. The final string is:
00011
Example
Input
01010
Output
3