Valera considers a number beautiful, if it equals 2^{k} or -2^{k} 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| ≤ 10^6), 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 2^3 + ( - 2^0).

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

Source: codeforces | Difficulty: HARD
Tags: Number theory

Dynamic programming

Game theory

Greedy algorithms


Solutions:
bin_num = input()
result = int(bin_num[0])
change = False
for i in range(1, len(bin_num)):
	if bin_num[i - 1] != bin_num[i]:
		if change:
			change = False
			result += 1
		else:
			change = True
	else:
		change = True
print(result + int(change and bin_num[len(bin_num) - 1] == '1'))


t = input()
j = t[0]
(d, s) = (0, int(j))
for i in t[1:]:
	if j != i:
		if d == 1:
			(d, s) = (0, s + 1)
		else:
			d = 1
		j = i
	else:
		d = 1
print(s + (d and j == '1'))


from math import *
from collections import *
a = list(input())
a = a[::-1]
n = len(a)
ct = 1
i = 0
while i < n - 1:
	if a[i] == '0':
		i += 1
		continue
	cnt = 0
	while i < n - 1 and a[i] == '1' and (a[i + 1] == '1'):
		cnt += 1
		i += 1
	if i == n - 1:
		ct += 1
	else:
		if cnt != 0:
			a[i + 1] = '1'
		ct += 1
		i += 1
print(ct)