CF279E.Beautiful Decomposition

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Valera considers a number beautiful, if it equals 2k2^{k} or - 2k2^{k} for some integer kk (k>=0)(k>=0) . Recently, the math teacher asked Valera to represent number nn as the sum of beautiful numbers. As Valera is really greedy, he wants to complete the task using as few beautiful numbers as possible.

Help Valera and find, how many numbers he is going to need. In other words, if you look at all decompositions of the number nn into beautiful summands, you need to find the size of the decomposition which has the fewest summands.

输入格式

The first line contains string ss (1<=s<=106)(1<=|s|<=10^{6}) , that is the binary representation of number nn without leading zeroes (n>0) .

输出格式

Print a single integer — the minimum amount of beautiful numbers that give a total of nn .

输入输出样例

  • 输入#1

    10
    

    输出#1

    1
    
  • 输入#2

    111
    

    输出#2

    2
    
  • 输入#3

    1101101
    

    输出#3

    4
    

说明/提示

In the first sample n=2n=2 is a beautiful number.

In the second sample n=7n=7 and Valera can decompose it into sum 23+(20)2^{3}+(-2^{0}) .

In the third sample n=109n=109 can be decomposed into the sum of four summands as follows: 27+(24)+(22)+202^{7}+(-2^{4})+(-2^{2})+2^{0} .

首页