Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.

Fangy takes some positive integer x and wants to get a number one from it. While x is not equal to 1, Fangy repeats the following action: if x is odd, then he adds 1 to it, otherwise he divides x by 2. Fangy knows that for any positive integer number the process ends in finite time.

How many actions should Fangy perform to get a number one from number x?

Input

The first line contains a positive integer x in a binary system. It is guaranteed that the first digit of x is different from a zero and the number of its digits does not exceed 106.

Output

Print the required number of actions.

Examples

Input

1


Output

0


Input

1001001


Output

12


Input

101110


Output

8

Note

Let's consider the third sample. Number 101110 is even, which means that we should divide it by 2. After the dividing Fangy gets an odd number 10111 and adds one to it. Number 11000 can be divided by 2 three times in a row and get number 11. All that's left is to increase the number by one (we get 100), and then divide it by 2 two times in a row. As a result, we get 1.

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
from collections import *

def add(n):
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '1':
			n[i] = '0'
		else:
			n[i] = '1'
			return n
	n.appendleft('1')
	return n

def main():
	(n, ans) = (deque(input()), 0)
	while len(n) != 1:
		if n[-1] == '1':
			n = add(n)
		else:
			n.pop()
		ans += 1
	print(ans)
main()


x = list(map(int, input()))
x = x[::-1]
l = len(x)
ans = 0
y = x.index(1)
ans += y
z = x[y:].count(0)
ans += z * 2
a = x.count(1)
if a != 1:
	ans += a + 1
print(ans)


x = str(input())
s = list(x)
s = [int(c) for c in s]
cur = 0
ans = 0
while len(s) > 1:
	if s[-1] ^ cur == 1:
		cur = 1
		ans += 1
	else:
		cur = s[-1] + cur >> 1
	ans += 1
	s.pop()
if cur == 1:
	ans += 1
print(ans)


x = list(map(int, input()))
cnt = 0
ans = 0
flag = 0
for i in range(1, len(x)):
	if x[-i] == 0:
		ans += 1
	elif x[-i - 1] == 1:
		if i == len(x) - 1:
			cnt += 3
		elif flag == 0:
			cnt += 1
			flag = 1
		else:
			cnt += 1
	else:
		x[-i - 1] = 1
		ans += cnt + 2
		flag = 0
		cnt = 0
	if i == len(x) - 1:
		ans += cnt
print(ans)


num = input()
x = len(num)
y = num.rfind('1')
z = num.count('1')
print(x + y - z + (2 if z > 1 else 0))


from sys import stdin
X = stdin.readline().strip()
carry = 0
ops = 0
for c in X[1:][::-1]:
	c = c == '1'
	if carry:
		if c:
			ops += 1
		else:
			ops += 2
	elif c:
		carry = 1
		ops += 2
	else:
		ops += 1
x = X[0] == '1'
if carry:
	if x:
		ops += 1
	else:
		pass
elif x:
	pass
else:
	raise ArithmeticError
print(ops)


num = input()
ans = 0
carry = '0'
for i in range(len(num) - 1, 0, -1):
	ans += 1
	if num[i] != carry:
		ans += 1
		carry = '1'
if carry == '1':
	ans += 1
print(ans)


string = input()
list1 = list(string)
list1 = list(map(int, list1))
count = 0
for x in range(len(string) - 1, 0, -1):
	if list1[x] == 0:
		count += 1
	elif list1[x] == 1:
		count += 2
		list1[x - 1] += 1
	else:
		count += 1
		list1[x - 1] += 1
if list1[0] == 2:
	count += 1
print(count)


s = list(input()[::-1])
i = 0
l = len(s)
carry = False
c = 0
if s.count('1') == 1:
	print(l - 1)
	exit(0)
while i < l:
	if s[i] == '1':
		if not carry:
			c += 2
			i += 1
			carry = True
		else:
			s[i] = '0'
			c += 1
			i += 1
	elif carry:
		s[i] = '1'
		carry = False
	else:
		c += 1
		i += 1
print(c)


s = list(input())
n = len(s) - 1
ans = 0
while s[n] != '1':
	ans += 1
	n -= 1
if n == 0:
	print(ans)
	exit()
counter = 0
while n >= 0:
	if s[n] != '0':
		counter += 1
		n -= 1
		continue
	ans += counter + 1
	s[n] = '1'
	counter = 0
ans += counter + 1
print(ans)


a = list(map(int, input()))
ans = 0
if a.index(1) != 0 or a.count(1) > 1:
	ans += a.count(1) + 1
a = a[::-1]
ans += a[:a.index(1)].count(0) + a[a.index(1):].count(0) * 2
print(ans)


x = list(map(int, input()))[::-1]
l = len(x)
a = x.index(1)
n = a
b = x[a:].count(0)
n += b * 2
a = x.count(1)
if a != 1:
	n += a + 1
print(n)


import sys
import math
n = sys.stdin.readline()
l = len(n) - 1
res = 0
carry = 0
for i in range(l - 1, 0, -1):
	current = n[i]
	if current == '0' and carry == 0:
		res += 1
	elif current == '1' and carry == 1:
		res += 1
		carry = 1
	elif current == '1' and carry == 0:
		res += 1
		carry = 1
	elif current == '0' and carry == 1:
		res += 2
		carry = 1
if carry == 1:
	res += 2
print(res)


x = input()
lx = len(x)
numop = 0
if x.endswith('0'):
	f = x.rindex('1')
	numop += lx - f - 1
	lx = f + 1
if lx == 1:
	print(numop)
else:
	numop += x.count('0', 0, lx) + lx + 1
	print(numop)


def main():
	s = list(map(int, list(input())))
	c = 0
	count = 0
	for i in range(len(s) - 1, 0, -1):
		if c + s[i] == 2:
			count += 1
			c = 1
		elif c + s[i] == 0:
			count += 1
			c = 0
		else:
			count += 2
			c = 1
	if c + s[0] == 2:
		count += 1
	print(count)
main()


n = input()
zeros = len(n) - max(n[::-1].find('1'), 0) - 1
cnt1 = n[:zeros + 1].count('1')
ans = len(n) + zeros - cnt1 + 2 * (cnt1 > 1)
print(ans)


from sys import stdin, stdout
inp = lambda : (int(o) for o in stdin.readline().split())
sinp = lambda : (o for o in stdin.readline().split())
out = lambda : stdout.write(str(ans))
n = list(stdin.readline().strip())
n = n[::-1]
ans = 0
x = n.index('1')
ans += n[:x].count('0')
if n[x:].count('1') > 1:
	ans += n[x:].count('1') + 1
ans += n[x:].count('0') * 2
out()


bin = input().strip()
length = len(bin)
numOnes = bin.count('1')
if numOnes == 1:
	print(length - 1)
else:
	last = bin.rfind('1')
	print(last - (numOnes - 2) + length)


s = str(input())
(ct, check) = (0, 0)
for i in range(1, len(s)):
	if s[-i] == '1':
		if check == 1:
			ct += 1
		else:
			ct += 2
			check = 1
	elif check == 1:
		ct += 2
	else:
		ct += 1
if s[0] == '1' and check == 1:
	ct += 1
if s[0] == '0' and check == 1:
	ct += 2
print(ct)


s = input()
Ans = 0
s = s[::-1]
if len(s) == 1 and s[0] == '1':
	print(0)
elif s.index('1') == len(s) - 1:
	print(len(s) - 1)
else:
	t = s.index('1')
	Ans += t + 2
	for i in range(t + 1, len(s)):
		if s[i] == '0':
			Ans += 2
		else:
			Ans += 1
	print(Ans)


import collections as clt
x = input()
d = clt.deque()
for i in x:
	d.append(i)
cnt = 0
while len(d) != 1:
	if d[-1] == '0':
		cnt += 1
		d.pop()
	else:
		i = len(d) - 1
		while i >= 0 and d[i] == '1':
			d[i] = '0'
			i -= 1
		if i == -1:
			d.appendleft('1')
		else:
			d[i] = '1'
		cnt += 1
if d[0] == '0':
	cnt += 1
print(cnt)


s = input()
(k, c) = (0, 0)
i = len(s) - 1
while i:
	if s[i] == '1':
		k += 2 - c
		c = 1
	else:
		k += 1 + c
	i -= 1
print(k + c)


s = input()
n = len(s)
c1 = s.count('1')
l1 = s.rfind('1')
if c1 == 1:
	print(n - 1)
else:
	print(n + l1 - c1 + 2)


x = input()
y = x.count('1')
print(len(x) + x.rfind('1') - y + 2 * (y > 1))


n = list(input())
n = n[::-1]
x = n.index('1')
print(n[:x].count('0') + (n[x:].count('1') + 1) * (n[x:].count('1') > 1) + n[x:].count('0') * 2)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
s = input()
n = len(s)
a = []
for i in range(n - 1, -1, -1):
	if s[i] == '1':
		a.append(i)
ans = n - a[0] - 1
n = len(a)
f = 0
if len(a) == 1:
	print(ans)
	exit()
for i in range(n - 1):
	d = a[i] - a[i + 1]
	ans += 2 * (d - f) + 1
	f = 1
print(ans)


n = str(input())
length = len(n)
nOnes = n.count('1')
last = n.rfind('1')
if nOnes == 1:
	print(last - nOnes + length)
else:
	print(last - nOnes + length + 2)


a = input()
if a == '1':
	print(0)
	exit()
ans = 0
if a.count('1') > 1:
	ans = ans + a.count('1') + 1
a = a[::-1]
ans += a[:a.index('1')].count('0') + a[a.index('1'):].count('0') * 2
print(ans)


bin = input().strip()
length = len(bin)
leastSignificantBit = bin.rfind('1')
numOnes = bin.count('1')
print(length + leastSignificantBit - numOnes + (2 if numOnes > 1 else 0))


import bisect
from itertools import accumulate
import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
a = input()[::-1].replace('', ' ').split()
z = len(a) - 1
ans = 0
i = 0
while i < z:
	if a[i] == '0':
		while i < z and a[i] == '0':
			i += 1
			ans += 1
	else:
		ans += 1
		while i < z and a[i] == '1':
			i += 1
			ans += 1
		if i == z:
			ans += 1
		a[i] = '1'
print(ans)


I = lambda : list(map(int, input().split()))
s = input()
n = len(s)
o = s.count('1')
l = s.rfind('1')
if o == 1:
	print(n + l - o)
else:
	print(n + l - o + 2)


a = input()[::-1].replace('', ' ').split()
z = len(a) - 1
ans = 0
i = 0
while i < z:
	if a[i] == '0':
		while i < z and a[i] == '0':
			i += 1
			ans += 1
	else:
		ans += 1
		while i < z and a[i] == '1':
			i += 1
			ans += 1
		if i == z:
			ans += 1
		a[i] = '1'
print(ans)


s = input()
ans = 0
n = len(s)
index = n - 1
zeros = 0
ones = 0
while s[index] == '0':
	index -= 1
	ans += 1
if index == 0:
	print(ans)
else:
	while index >= 0:
		if s[index] == '0':
			zeros += 1
		else:
			ones += 1
		index -= 1
	print(ans + ones + 2 * zeros + 1)


n = input().strip()
cnt = 0
mode = 0
for (i, d) in enumerate(reversed(n)):
	if mode:
		if d == '1':
			cnt += 1
		else:
			cnt += 2
	else:
		if i == len(n) - 1:
			break
		if d == '1':
			cnt += 2
			mode = 1
		else:
			cnt += 1
print(cnt)


s = input()
steps = 0
i = len(s) - 1
while i > 0 and s[i] == '0':
	steps += 1
	i -= 1
prev_i = i
while i > 0:
	i -= 1
	while i >= 0 and s[i] == '1':
		i -= 1
	steps += prev_i - i + 1
	prev_i = i
print(steps)


s = input()
actions = 0
if len(s) > 1:
	if s.rfind('1') == 0:
		actions = len(s) - 1
	else:
		actions = len(s) + s[:s.rfind('1')].count('0') + 1
print(actions)


inp = input()
num = '2' + inp[::-1] + '2'
if num == '212':
	print(0)
	exit()
last = num[0]
conseq = 0
count = 0
for i in range(len(num)):
	digit = num[i]
	if digit == last:
		conseq += 1
	else:
		if last == '0':
			count += conseq
			if i == len(num) - 2:
				break
		elif last == '1':
			count += conseq + 1
			digit = '1'
		last = digit
		conseq = 1
print(count)


binstr = input()
count = 0
l = len(binstr) - 1
while l > 0 and binstr[l] == '0':
	count += 1
	l -= 1
if l != 0:
	count += (l + 1) * 2
while l > 0:
	if binstr[l] == '1':
		count -= 1
	l -= 1
print(count)


import sys

def solve():
	binary = input()
	(length, lastone, numone) = (len(binary), binary.rfind('1'), binary.count('1'))
	ans = length + lastone - numone
	ans += 2 if numone > 1 else 0
	print(ans)
solve()


import io
import os
import sys
from atexit import register
import random
import math
import itertools
DEBUG = False
STRESSTEST = False
if not DEBUG:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	if type(tokens[tokens_next - 1]) == str:
		return tokens[tokens_next - 1]
	return tokens[tokens_next - 1].decode()

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(*argv, end='\n'):
	for arg in argv:
		sys.stdout.write((str(arg) + ' ').encode())
	sys.stdout.write(end.encode())

def genTestCase():
	n = random.randint(1, 10)
	return '1' + ''.join((str(random.randint(0, 1)) for _ in range(n - 1)))

def bruteforce(s):
	res = 0
	n = int(s, 2)
	while n > 1:
		if n % 2 == 0:
			n //= 2
			res += 1
		else:
			n += 1
			res += 1
	return res

def doStressTest():
	while True:
		curTest = genTestCase()
		mySoln = solve(curTest)
		bruteforceSoln = bruteforce(curTest)
		if mySoln != bruteforceSoln:
			print('### Found case ###')
			print(curTest)
			print(f'{mySoln} should have been: {bruteforceSoln}')
			return

def solve(s):
	a = map(int, s)
	a = list(a)
	a = a[::-1]
	res = 0
	carry = 0
	for i in range(len(a)):
		if a[i] == carry:
			res += 1
		elif a[i] == 0:
			res += 2
		elif i == len(a) - 1 and carry == 0:
			pass
		else:
			res += 2
			carry = 1
	return res
if not DEBUG and STRESSTEST:
	raise Exception('Wrong flags!')
if STRESSTEST:
	doStressTest()
else:
	res = solve(nextStr())
	print(res)
sys.stdout.flush()


from sys import stdin
num = stdin.readline().rstrip()
if len(num) == 1:
	if num == '1':
		print(0)
	else:
		print(1)
else:
	spot = len(num) - 1
	numOps = 0
	while spot >= 0 and num[spot] == '0':
		numOps += 1
		spot -= 1
	if not spot == 0:
		numOps += 2
	spot -= 1
	while spot >= 0:
		if num[spot] == '1':
			numOps += 1
		else:
			numOps += 2
		spot -= 1
	print(numOps)


from sys import stdin
__author__ = 'artyom'
digits = list(stdin.readline().strip())
count = 0
for i in range(len(digits) - 1, 0, -1):
	count += 1
	if digits[i] == '1' and digits[i - 1] != '1':
		digits[i - 1] = '1'
		count += 1
	if len(digits) > 1 and i == 1 and (digits[i] == '1'):
		count += 2
print(count)


import math
import queue
from itertools import permutations
s = input()
t = '1' + (len(s) - 1) * '0'
a = 0
b = 0
for i in range(0, len(s)):
	if s[i] == '0':
		a += 1
i = len(s) - 1
while True:
	if s[i] == '1':
		break
	b += 1
	i -= 1
answer = len(s) + 1 + a - b
if s != t:
	print(answer)
else:
	print(len(s) - 1)


import sys
from array import array

def input():
	return sys.stdin.buffer.readline().decode('utf-8')
x = list(map(int, input().rstrip()))
y = 0
ans = 0
while len(x) > 1:
	if x[-1] ^ y == 1:
		y = 1
		ans += 1
	else:
		y = x[-1] + y >> 1
	ans += 1
	x.pop()
if y == 1:
	ans += 1
print(ans)


s = input()
k = 0
ans = 0
t = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == '0' and t == 0:
		ans += 1
	elif s[i] == '0' and t == 1:
		ans += 2
	if s[i] == '1' and t == 0:
		ans += 2
		t = 1
	elif s[i] == '1' and t == 1:
		ans += 1
	if s[i] == '0':
		k += 1
if s[0] == '1' and k == len(s) - 1:
	ans -= 2
print(ans)


num = input()
ans = 0
carry = 0
i = len(num) - 1
while i > 0:
	if num[i] == '0' and carry == 0:
		ans += 1
	elif num[i] == '0' and carry == 1:
		ans += 2
	elif num[i] == '1' and carry == 0:
		carry = 1
		ans += 2
	elif num[i] == '1' and carry == 1:
		carry = 1
		ans += 1
	i -= 1
if carry == 1:
	ans += 1
print(ans)


n = input()
length_num = len(n)
last_i = n.rfind('1')
one_count = n.count('1')
if one_count == 1:
	print(length_num + last_i - one_count)
else:
	print(length_num + last_i - one_count + 2)


n = list(map(int, input()))
l = 0
count = 0
for i in range(len(n) - 1, -1, -1):
	if n[i] == 0 and l == 0:
		count += 1
	elif n[i] == 0 and l == 1:
		count += 2
	elif n[i] == 1 and i != 0:
		count += 1
		l = 1
	elif n[i] == 1 and l == 1:
		count += 2
print(count)


import sys
n = list((int(x) for x in input().rstrip('\n')))
edge = False
count = 0
for i in range(len(n) - 1, -1, -1):
	if n[i] == 0 and (not edge):
		count += 1
	elif n[i] == 0 and edge:
		count += 2
	elif n[i] == 1 and i != 0:
		count += 1
		edge = True
	elif n[i] == 1 and edge:
		count += 2
print(count)


s = input()
n = len(s)
s = list(s)
ans = 0
for i in range(n - 1, 0, -1):
	if s[i] == '0':
		ans += 1
	elif s[i] == '2':
		ans += 1
		s[i - 1] = str(int(s[i - 1]) + 1)
	elif s[i] == '1':
		ans += 2
		s[i - 1] = str(int(s[i - 1]) + 1)
if s[0] == '2':
	ans += 1
print(ans)


s = input()
z = s.count('1')
ans = len(s) + s.rfind('1') - z
if z != 1:
	ans += 2
print(ans)


from sys import stdin, stdout

def solve(N):
	(ops, carry) = (0, int(N[-1]))
	prevcarry = -1
	i = len(N) - 1
	while i > 0:
		while carry == 0:
			i -= 1
			ops += 1
			prevcarry = carry
			carry = int(N[i])
		while i > 0 and int(N[i - 1]) == 1:
			ops += 1
			prevcarry = carry
			i -= 1
		carry = 1
		if i > 0 and int(N[i - 1]) == 0 or carry & prevcarry:
			ops += 2
			i -= 1
			prevcarry = carry
	return ops
N = input()
stdout.write(str(solve(N)) + '\n')


bin_nums = input()
i = len(bin_nums) - 1
bin_nums = list(map(int, bin_nums))
count = 0
num_1s = 0
while i > 0:
	if i == len(bin_nums) - 1 and (not bin_nums[i]):
		count += 1
		i -= 1
		while not bin_nums[i]:
			count += 1
			i -= 1
	else:
		i -= 1
		while i >= 0 and bin_nums[i]:
			num_1s += 1
			i -= 1
		count += num_1s + 2
		num_1s = 0
print(count)