跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2530. Beautiful Decomposition

  • ID: 2536
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:提高
  • 上传者:
  • 动态规划
  • 博弈
  • 贪心
  • 数论
  • 数学
  • 算法思想
  • 提高
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Beautiful Decomposition

题目描述

E. Beautiful Decomposition
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Valera considers a number beautiful, if it equals 2k or -2k for some integer k (k≥0). Recently, the math teacher asked Valera to represent number n 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 n into beautiful summands, you need to find the size of the decomposition which has the fewest summands.

Input

The first line contains string s (1≤|s|≤106), that is the binary representation of number n without leading zeroes (n>0).

Output

Print a single integer − the minimum amount of beautiful numbers that give a total of n.

Examples
Input
10
Output
1
Input
111
Output
2
Input
1101101
Output
4
Note

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

In the second sample n=7 and Valera can decompose it into sum 23+(-20).

In the third sample n=109 can be decomposed into the sum of four summands as follows: 27+(-24)+(-22)+20.


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2175 题。保留原作者与原赛事署名。