Lowbit
题号:NC253172
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

One day Colin learned how to represent a number in binary form. For example, the binary form of (11)_{10} is (1011)_{2} , and he was very excited!

Further, Eva taught Colin a well-known binary function \text{lowbit}(x) which represents the value of the bit corresponding to the lowest 1 of x in binary form. For example, \text{lowbit}(11) = 1 , \text{lowbit}(4) = 4

Colin thought this function was amazing, so he thought of an interesting problem, and then it comes:

Given a binary form of a number x(x\le 2^{10^5}) , you need to perform some operations on x.
Each turn you can choose one of the following two operations:
  • \mathbf{x+=lowbit(x)} , which means adding the lowest bit of x to x
  • \mathbf{x-=lowbit(x)} , which means subtracting the lowest bit of x from x
Now Colin wants to know, what is the minimum number of operations required to turn x into 0?

输入描述:

A single line with the binary form of x \text{ } (1 \le x\le 2^{10^5}) without leading zero.

输出描述:

One integer, the minimum number of operations required.
示例1

输入

复制
1100101

输出

复制
4