Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10^{k}.

In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10^{k}. For example, if k = 3, in the number 30020 it is enough to delete a single digit (2). In this case, the result is 3000 that is divisible by 10^3 = 1000.

Write a program that prints the minimum number of digits to be deleted from the given integer number n, so that the result is divisible by 10^{k}. The result should not start with the unnecessary leading zero (i.e., zero can start only the number 0, which is required to be written as exactly one digit).

It is guaranteed that the answer exists.


-----Input-----

The only line of the input contains two integer numbers n and k (0 ≤ n ≤ 2 000 000 000, 1 ≤ k ≤ 9).

It is guaranteed that the answer exists. All numbers in the input are written in traditional notation of integers, that is, without any extra leading zeros.


-----Output-----

Print w — the required minimal number of digits to erase. After removing the appropriate w digits from the number n, the result should have a value that is divisible by 10^{k}. The result can start with digit 0 in the single case (the result is zero and written by exactly the only digit 0).


-----Examples-----
Input
30020 3

Output
1

Input
100 9

Output
2

Input
10203049 2

Output
3



-----Note-----

In the example 2 you can remove two digits: 1 and any 0. The result is number 0 which is divisible by any number.

Source: codeforces | Difficulty: EASY
Tags: Complete search

Greedy algorithms


Solutions:
(n, k) = map(int, input().split())
s = str(n)
(x, y) = (0, 0)
f = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == '0':
		x = x + 1
	else:
		y = y + 1
	if x == k:
		f = 1
		break
if f == 1:
	print(y)
else:
	print(len(s) - 1)


(n, k) = list(map(int, input().split()))
if n < pow(10, k):
	print(len(str(n)) - 1)
elif list(str(n)).count('0') < k:
	print(len(str(n)) - 1)
else:
	n = str(n)
	n = n[::-1]
	x = 0
	p = 0
	for y in n:
		if p != k:
			if y == '0':
				x -= 1
				p += 1
			else:
				x -= 1
				pass
		else:
			break
	lk = 0
	n = n[::-1]
	for item in n[x:]:
		if item != '0':
			lk += 1
		else:
			pass
	print(lk)


(s, k) = input().split()
k = int(k)
(v, w, l) = (0, 0, len(s))
for i in reversed(range(l)):
	if s[i] == '0':
		v += 1
	elif not v >= k:
		w += 1
if v >= k:
	print(w)
else:
	print(l - 1)


def solve(test):
	(n, k) = test.split()
	k = int(k)
	cnt = 0
	rm_cnt = 0
	res = []
	for d in reversed(n):
		if d == '0' and cnt < k:
			res.append(d)
			cnt += 1
		elif cnt >= k:
			res.append(d)
		else:
			rm_cnt += 1
	if cnt < k:
		return len(n) - 1
	return rm_cnt

def get_input():
	return input()

def go():
	print(solve(get_input()))
go()


(n, k) = input().split()
k = int(k)
z = n.count('0')
if z < k:
	print(len(n) - 1)
else:
	n = n[::-1]
	p = 0
	ans = 0
	while p != k:
		if n[p] == '0':
			p = p + 1
		else:
			ans = ans + 1
			n = n[1:]
	print(ans)


data = list(map(int, input().split()))
n = str(data[0])
n_str = str(n)
k = data[1]
z = 10 ** k
counter = 0

def remove_last_digit(number):
	numero = list(str(number))
	for i in range(len(numero) - 1, -1, -1):
		if numero[i] != '0':
			numero = numero[0:i] + numero[i + 1:len(numero)]
			break
	if numero[0] == '0':
		global counter
		for i in range(0, len(numero) - 1):
			counter += 1
	return ''.join(numero)
if n == 0:
	print(0)
else:
	while True:
		if int(n) % z != 0:
			n = remove_last_digit(n)
			counter += 1
		else:
			break
print(counter)


(n, k) = input().split()
k = int(k)
n = n[::-1]
zeros = 0
i = 0
de = 0
while zeros < k and i < len(n):
	if n[i] == '0':
		zeros += 1
	else:
		de += 1
	i += 1
if i == len(n):
	print(i - 1)
else:
	print(de)


(n, k) = map(str, input().split())
length = len(n)
count0 = 0
count1 = 0
flag = 0
for x in range(0, length):
	if n[length - x - 1] == '0':
		count0 += 1
	else:
		count1 += 1
	if count0 == int(k):
		flag = 1
		break
if flag == 1:
	print(count1)
else:
	print(length - 1)


(a, n) = map(str, input().split())
k = len(a)
n = int(n)
count = 0
count2 = 0
if len(a) <= n:
	print(len(a) - 1)
else:
	while count < n and k > 0:
		if a[k - 1] == '0':
			count += 1
			k -= 1
		else:
			k -= 1
			count2 += 1
	if count == n:
		print(count2)
	else:
		print(len(a) - 1)


(n, k) = input().split()
k = int(k)
if len(n) <= k:
	print(len(n) - 1)
	exit(0)
digits_removed = 0
trailing_zeros = 0
for digit in reversed(n):
	if digit == '0':
		trailing_zeros += 1
		if trailing_zeros == k:
			break
	else:
		digits_removed += 1
print(digits_removed if trailing_zeros == k else len(n) - 1)


t = cnt = 0
(n, k) = input().split()
if len(n) <= int(k):
	print(len(n) - 1)
else:
	k = int(k)
	for (a, i) in enumerate(n[::-1]):
		if i != '0':
			t += 1
		else:
			cnt += 1
		if cnt == k:
			break
	print(t if t != len(n) - n.count('0') else len(n) - 1)


(n, k) = input().split()
k = int(k)
n = list(n)[::-1]
ans = 0
has_zero = False
for i in range(len(n)):
	if n[i] != '0':
		ans += 1
	else:
		has_zero = True
		k -= 1
		if k == 0:
			print(ans)
			exit()
print(len(n) - has_zero)


def main():
	(n, k) = list(map(int, input().split()))
	if n == 0 or k == 0:
		print(0)
	else:
		s = str(n)
		res = 0
		for i in range(len(s) - 1, -1, -1):
			if s[i] == '0':
				k -= 1
			else:
				res += 1
			if k == 0:
				break
		if k == 0:
			print(res)
		else:
			print(len(s) - 1)

def __starting_point():
	main()
__starting_point()


[n, k] = map(int, input().split())
ns = str(n)
if k == 0:
	print(len(ns) - 1)
else:
	ct = 0
	ct0 = 0
	for i in range(len(ns)):
		if ns[len(ns) - i - 1] != '0':
			ct += 1
		else:
			ct0 += 1
		if ct0 == k:
			break
	if ct0 == k:
		print(ct)
	else:
		print(len(ns) - 1)


(n, k) = [int(x) for x in input().split()]
count = 0
o_count = 0
x = n
for i in range(len(str(x))):
	if x % 10 != 0:
		count += 1
	else:
		o_count += 1
	x //= 10
	if o_count == k:
		break
if o_count < k:
	count = len(str(n)) - 1
print(count)


(n, k) = input().split()
k = int(k)
s = sum(map(lambda x: x == '0', n))
if s < k:
	print(len(n) - 1)
else:
	res = 0
	for ch in reversed(n):
		if ch == '0':
			k -= 1
			if not k:
				break
		else:
			res += 1
	print(res)


(n, k) = input().split()
k = int(k)
if n.count('0') < k:
	print(len(n) - 1)
else:
	count = 0
	for i in n[::-1]:
		if k > 0:
			if i != '0':
				count += 1
			else:
				k -= 1
		else:
			break
	print(count)


(n, k) = map(int, input().split())
n = list(str(n))
n.reverse()
note = list()
(s, t) = (len(n), 0)
for i in range(s):
	if n[i] == '0':
		note.append(i)
		t += 1
if t < k:
	print(s - 1)
else:
	print(note[k - 1] - (k - 1))


(n, k) = [int(i) for i in input().split()]
n = str(n)
ans = 0
t = 0
i = len(n) - 1
while i > -1 and t < k:
	if n[i] != '0':
		ans += 1
	else:
		t = t + 1
	i = i - 1
if k >= len(n) or n.count('0') < k:
	ans = len(n) - 1
print(ans)


(n, k) = map(int, input().split())
(c, z) = (0, 0)
if n == 0:
	print(0)
	exit()
while n:
	c += 1
	if n % 10 == 0:
		z += 1
		if z == k:
			print(c - z)
			exit()
	n //= 10
print(c - 1)


(n, k) = map(int, input().split())
c = 0
ans = 0
while n != 0:
	s = n % 10
	if s == 0:
		c += 1
	if s != 0:
		ans += 1
	if c >= k:
		break
	n = n // 10
if c < k:
	if c > 0:
		print(ans + c - 1)
	else:
		print(0)
else:
	print(ans)


(s, n) = (z for z in input().split())
n = int(n)
if s.count('0') < n:
	print(len(s) - 1)
else:
	cnt = 0
	i = 1
	while cnt < n:
		if s[-i] == '0':
			cnt += 1
		i += 1
	print(i - 1 - cnt)


(n, k) = input().split()
k = int(k)
num_0 = n.count('0')
cnt = 0
ans = 0
if num_0 >= k:
	for ch in n[::-1]:
		if ch == '0':
			cnt += 1
		else:
			ans += 1
		if cnt >= k:
			break
else:
	ans = len(n) - 1
print(ans)


a = input().split()
b = [int(q) for q in list(a[0])]
k = int(a[1])
if b.count(0) < k:
	print(len(b) - 1)
else:
	b = b[::-1]
	ct = 0
	t = 0
	for r in range(len(b)):
		if b[r] == 0:
			t += 1
			if t == k:
				break
		else:
			ct += 1
	print(ct)


(n, k) = input().split(' ')
k = int(k)
ans = 0
for i in range(0, len(n))[::-1]:
	ch = n[i]
	if n[i] == '0':
		k -= 1
		if k == 0:
			break
	else:
		ans += 1
if k != 0:
	print(len(n) - 1)
else:
	print(ans)


(n, k) = map(int, input().split())
n = str(n)
ind = -1
f = 0
for i in range(1, len(n) + 1):
	if n[-i] == '0':
		f += 1
	if f == k:
		ind = i
		break
if ind == -1:
	print(len(n) - 1)
else:
	print(ind - k)


import sys
import re
input = lambda : sys.stdin.readline()
import functools

@functools.lru_cache(maxsize=10000)
def Main():
	(s, k) = input().split()
	k = int(k)
	zr = s.count('0')
	ln = len(s)
	ss = s[::-1]
	dgt = 0
	zero = 0
	if zr == len(s):
		print(len(s) - 1)
		return 0
	if s == '0':
		print(0)
		return 0
	elif k > len(s):
		print(len(s) - 1)
	elif k > zr:
		print(len(s) - 1)
	else:
		for i in range(len(ss)):
			if ss[i] == '0':
				zero += 1
				if zero == k:
					dgt = i
					break
		res = 0
		for i in range(dgt + 1):
			if ss[i] != '0':
				res += 1
		print(res)
Main()


(n, k) = input().split()
k = int(k)
ans = 0
zerocount = 0
i = 1
try:
	if len(n) > k:
		while zerocount != k:
			if n[-1 * i] != '0':
				ans += 1
			else:
				zerocount += 1
			i += 1
	else:
		ans = len(n) - 1
except:
	ans = len(n) - 1
print(ans)


(n, k) = input().split()
k = int(k)
tot = n.count('0')
if tot < k:
	print(len(n) - 1)
else:
	(zeros, ans) = (0, 0)
	j = len(n) - 1
	while zeros < k:
		if n[j] == '0':
			zeros += 1
		else:
			ans += 1
		j -= 1
	print(ans)


(a, b) = input().split()
b = int(b)
n = len(a)
m = a.count('0')
x = 0
if m < b:
	print(str(n - 1))
else:
	for i in range(1, n + 1):
		if a[-i] == '0':
			b -= 1
		else:
			x += 1
		if b == 0:
			break
	print(x)


(n, k) = input().split()
k = int(k)
w = 0
zeros = 0
for digit in n[::-1]:
	if digit == '0':
		zeros += 1
		if zeros == k:
			break
	else:
		w += 1
if zeros != k:
	w = len(n) - 1
print(w)


(n, k) = input().split()
nn = len(n)
kk = int(k)
if nn < kk:
	print(nn - 1)
else:
	p = kk
	i = len(n) - 1
	l = 0
	while p > 0 and i >= 0:
		if n[i] != '0':
			n = n[:i] + n[i + 1:]
			l += 1
			i -= 1
		else:
			p -= 1
			i -= 1
	if len(n) < kk:
		print(nn - 1)
	else:
		print(l)


(n, k) = input().split()
k = int(k)
zeroCount = 0
ans = 0
for i in range(len(n) - 1, -1, -1):
	if n[i] == '0':
		zeroCount += 1
	if zeroCount == k:
		print(ans)
		exit(0)
	if n[i] != '0':
		ans += 1
print(ans + zeroCount - 1)


(a, b) = input().split()
b = int(b)
x = pow(10, b)
d = 0
l = list(a)
if int(a) % x == 0:
	print(0)
else:
	for i in range(len(a) - 1, -1, -1):
		if a[i] != '0':
			del l[i]
			d = d + 1
			if l[-b:] == b * ['0']:
				print(d)
				break
	else:
		print(len(a) - 1)


(n, k) = input().split()
k = int(k)
m = []
a = 0
b = 0
for i in range(len(n)):
	m.append(n[i])
for j in range(len(n) - 1, -1, -1):
	if m[j] == '0':
		a += 1
		if a == k:
			break
	else:
		del m[j]
		b += 1
if a < k or m[0] == '0':
	print(len(n) - 1)
else:
	print(b)


(n, k) = map(int, input().split())
n = str(n)
if len(n) <= k:
	print(len(n) - 1)
else:
	n = str(n)
	count = 0
	ans = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			count = count + 1
			if count == k:
				break
		else:
			ans = ans + 1
	if count != k:
		print(len(n) - 1)
	else:
		print(ans)


[n, k] = list(map(int, input().split()))
cnt0 = 0
n = str(n)
for i in range(len(n)):
	if n[i] == '0':
		cnt0 += 1
if cnt0 >= k:
	sol = 0
	rem0 = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] != '0':
			sol += 1
		else:
			rem0 += 1
		if rem0 == k:
			break
	print(sol)
elif cnt0 == 0:
	print(len(n))
else:
	print(len(n) - 1)


def weird_round(n, k):
	zeros = 0
	removed = 0
	for d in reversed(n):
		if zeros == k:
			return removed
		elif d == '0':
			zeros += 1
		else:
			removed += 1
	return len(n) - 1
(n, k) = input().split()
k = int(k)
print(weird_round(n, k))


a = input()
a = a.split()
findInstr = a[0]
a[1] = int(a[1])
recommendedZeroCounter = 0
minimumCounter = 0
zeroEnough = 0
for i in range(len(a[0]) - 1, 0, -1):
	if findInstr[i] == '0':
		recommendedZeroCounter += 1
if recommendedZeroCounter < a[1]:
	print(len(a[0]) - 1)
else:
	for i in range(len(a[0]) - 1, 0, -1):
		if findInstr[i] != '0':
			minimumCounter += 1
		if findInstr[i] == '0':
			zeroEnough += 1
		if zeroEnough == a[1]:
			break
	print(minimumCounter)


(n, k) = map(int, input().split())
A = list(str(n))
A = A[::-1]
_k = k
i = 0
ans = 0
while k and i < len(A):
	if A[i] != '0':
		ans += 1
	else:
		k -= 1
	i += 1
if k:
	if k != _k:
		print(len(A) - 1)
	else:
		print(len(A))
else:
	print(ans)


from sys import maxsize, stdout, stdin, stderr
import re
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
(s, k) = S().split()
(k, n, s, c) = (int(k), len(s), list(s), 0)
i = n - 1
while i >= 0:
	p = ''.join([j for j in s if j != '-1'])
	if int(int(p[-k:]) % 10 ** k) == 0:
		break
	if s[i] != '0':
		s[i] = '-1'
		c += 1
	i -= 1
x = [u for u in s if u != '-1']
if x.count('0') == len(x):
	print(c + (x.count('0') - 1))
else:
	print(c)


(n, m) = input().split()
(n, m) = (list(n)[::-1], int(m))
k = 0
i = 0
ans = 0
p = len(n)
if p <= m:
	print(p - 1)
elif n.count('0') < m:
	print(p - 1)
else:
	while k != m and i < p:
		if n[i] == '0':
			k += 1
		else:
			ans += 1
		i += 1
	print(ans)


(n, k) = [x for x in input().split()]
k = int(k)
ans = 0
stack = 0
if k == 0:
	print(0)
if n.count('0') < k:
	print(len(n) - 1)
else:
	for i in n[::-1]:
		if stack == k:
			break
		if i == '0':
			stack += 1
		else:
			ans += 1
	print(ans)


L = input()
L = L.split()
n = L[0]
k = int(L[1])

def Div(N, K):
	N = int(N)
	if N % 10 ** K == 0:
		return True
	else:
		return False
c = 0
f = len(n)
while f != 1:
	f -= 1
	if n[f] != '0' and (not Div(n, k)):
		b = n[:f] + n[f + 1:]
		n = b
		c += 1
	else:
		b = n
if int(n) == 0:
	print(c)
else:
	nd = len(b)
	nceros = nd - 1
	if nceros < k:
		c = nceros + c
	print(c)


(n, k) = input().split()
k = int(k)
current = len(n) - 1
zeros = 0
ans = 0
done = 0
while current >= 0:
	if zeros == k:
		print(ans)
		done = 1
		break
	if n[current] == '0':
		current -= 1
		zeros += 1
	else:
		n = n[:current] + n[current + 1:]
		current -= 1
		ans += 1
if done == 0:
	ans += zeros - 1
	print(ans)


(n, k) = input().split()
k = int(k)
dig = 0
zeros = 0
for i in range(len(n) - 1, 0, -1):
	if n[i] != '0':
		dig += 1
	else:
		zeros += 1
	if zeros >= k:
		print(dig)
		exit()
print(len(n) - 1)


(n, k) = map(str, input().strip().split())
k = int(k)
num = str(10 ** k)
if len(n) < len(num):
	print(len(n) - 1)
else:
	(c, z) = (0, 0)
	for i in range(len(n) - 1, -1, -1):
		if n[i] != '0':
			c += 1
		else:
			z += 1
		if z == k:
			break
	if z >= k:
		print(c)
	else:
		print(len(n) - 1)


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	(n, k) = input().split()
	k = int(k)
	zcnt = 0
	ans = 0
	for d in reversed(n):
		if d == '0':
			zcnt += 1
			if zcnt == k:
				print(ans)
				return
		else:
			ans += 1
	ans = len(n) - 1
	print(ans)
solve()


(nu, k) = input().split()
k = int(k)
nu = list(nu)
count = 0
need = k
i = len(nu) - 1
while need > 0:
	dig = nu[i]
	if dig == '0':
		need -= 1
		i -= 1
	else:
		count += 1
		del nu[i]
		i -= 1
	if int(''.join(nu)) == 0:
		count += len(nu) - 1
		break
print(count)


(n, k) = [x for x in input().split()]
cnt = 0
k = int(k)
l = len(n)
for i in range(l - 1, -1, -1):
	if k <= 0:
		break
	elif n[i] == '0':
		k -= 1
	else:
		cnt += 1
if k <= 0:
	print(cnt)
else:
	print(l - 1)


(n, k) = [int(i) for i in input().split()]
if n % 10 ** k == 0:
	print(0)
	return
if str(n).count('0') < k:
	print(len(str(n)) - 1)
	return
ans = 0
st = str(n)
j = len(st) - 1
while int(st) % 10 ** k != 0:
	while int(st) % 10 ** k != 0 and st[j] != '0':
		st = st[:j] + st[j + 1:]
		j -= 1
		ans += 1
	while int(st) % 10 ** k != 0 and st[j] == '0':
		j -= 1
print(ans)


from sys import stdin, stdout
(num, k) = map(int, stdin.readline().rstrip().split())
numStr = str(num)
if num == 0:
	print(0)
elif numStr.count('0') == 0:
	print(len(numStr))
elif numStr.count('0') < k:
	print(len(numStr) - 1)
else:
	numReverse = numStr[::-1]
	zeroCount = 0
	deleted = 0
	i = 0
	while zeroCount < k:
		if numReverse[i] == '0':
			zeroCount += 1
		else:
			deleted += 1
		i += 1
	print(deleted)


(s, m) = input().split()
n = int(m)
s = s[::-1]
k = 0
d = 0
sd = ''
for i in s:
	if k != n:
		if i == '0':
			k += 1
		else:
			d += 1
print(d if k == n else len(s) - 1)


(n, k) = input().split()
n = list(n)
k = int(k)
zeroes = 0
digits_to_remove = 0
i = len(n) - 1
while True:
	if zeroes < k:
		if i == 0:
			digits_to_remove += len(n) - 1
			break
		elif n[i] == '0':
			zeroes += 1
		else:
			del n[i]
			digits_to_remove += 1
		i -= 1
	else:
		break
print(digits_to_remove)


(n, k) = list(map(int, input().split()))
k = 10 ** k
n = list(str(n))

def isNum(x):
	return not (len(x) == 0 or len(x) != len(str(int(''.join(x)))))

def isDiv(x):
	return isNum(x) and int(''.join(x)) % k == 0
if not '0' in n:
	print('0')
	exit()
out = 0
i = len(n) - 1
while i >= 0:
	if isDiv(n):
		break
	if n[i] != '0':
		out += 1
		del n[i]
	i -= 1
if not isNum(n):
	out += len(n) - len(str(int(''.join(n))))
print(out)


(a, k) = [i for i in input().strip().split(' ')]
a = [int(i) for i in a]
k = int(k)
alen = len(a)
index = alen - 1
cuts = 0
badInput = False
while k != 0:
	if index == -1:
		badInput = True
		break
	if a[index] == 0:
		k -= 1
	else:
		cuts += 1
	index -= 1
if badInput:
	print(alen - 1)
elif k == 0:
	print(cuts)
else:
	print('you fucked it')


def f():
	ipt = input().strip().split()
	k = int(ipt[1])
	ns = ipt[0]
	a = [int(i) for i in ns]
	n = len(a)
	flag = 1
	for i in a:
		if i == 0:
			flag = 0
			break
	if n < k + 1:
		if flag == 0:
			print(n - 1)
			return
		print(n)
		return
	count = 0
	d = 0
	for i in reversed(a):
		if count == k:
			print(d - count)
			return
		if i == 0:
			count += 1
		d += 1
	if flag == 0:
		print(n - 1)
		return
	print(n)
f()


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	(n, k) = input().split()
	n = [int(i) for i in n]
	k = int(k)
	cnt = 0
	while n[-k:].count(0) < len(n[-k:]):
		for i in range(max(0, len(n) - k), len(n)):
			if n[i] != 0:
				n[i] = -1
				cnt += 1
		n = [d for d in n if d >= 0]
	if n and n.count(0) == len(n):
		cnt += len(n) - 1
	print(cnt)
solve()


(n, k) = map(str, input().split())
a = list(n)
k = int(k)
if 10 ** k > int(n):
	print(len(n) - 1)
elif int(n) % 10 ** k == 0:
	print(0)
else:
	c = 0
	z = 0
	for i in range(len(a) - 1, -1, -1):
		if z == k:
			break
		if a[i] != '0':
			c = c + 1
		if a[i] == '0':
			z = z + 1
	if z < k:
		print(len(a) - 1)
	else:
		print(c)


import math, sys

def main():
	s = input().split()
	k = int(s[1])
	n = s[0]
	l = len(n)
	ans = 0
	for i in range(l):
		if i - ans == k:
			print(ans)
			sys.exit(0)
		if n[l - i - 1] != '0':
			ans += 1
	if l - ans > 0:
		print(l - 1)
main()


(n, K) = input().strip().split()
K = int(K)
cnt = 0

def check(n, k):
	a = int(n)
	if a == 0:
		if len(n) == 1:
			return a % 10 ** k == 0
		else:
			return False
	else:
		return a % 10 ** k == 0
while not check(n, K):
	if int(n) == 0 and len(n) > 1:
		n = n[1:]
		cnt += 1
		continue
	i = -1
	while n[i] == '0':
		i -= 1
	temp = list(n)
	temp.pop(i)
	n = ''.join(temp)
	cnt += 1
print(cnt)


(n, k) = input().split()
n = list(n)
k = int(k)
if len(n) <= k:
	print(len(n) - 1)
else:
	s = 0
	j = 0
	for i in n:
		if i == '0':
			j = j + 1
	if j < k:
		print(len(n) - 1)
	else:
		for i in n[::-1]:
			if i == '0':
				k = k - 1
			else:
				s = s + 1
			if k == 0:
				print(s)
				break


(n, k) = input().split()
k = int(k)
if n.count('0') < k:
	print(len(n) - 1)
else:
	print(sum([len(s) for s in n.split('0')[-k:]]))


(N, K) = map(int, input().split())
S = str(N)
if N % 10 ** K == 0:
	print(0)
elif int(S[1:]) == 0:
	print(len(S) - 1)
elif S.count('0') < K:
	print(len(S) - 1)
else:
	ans = 0
	for i in range(len(S) - 1, -1, -1):
		if S[i] == '0':
			K -= 1
		else:
			ans += 1
		if K == 0:
			break
	print(ans)


(n, k) = map(int, input().strip().split())
s = list(str(n))
s = s[::-1]
co = 0
if s.count('0') < k:
	if s.count('0') == 0:
		print(0)
	if s.count('0') >= 1:
		print(len(s) - 1)
else:
	for i in range(len(s)):
		if s[i] == '0':
			k -= 1
			if k == 0:
				break
		else:
			co += 1
	print(co)


(n, k) = input().strip().split()
k = int(k)
n_ = ''
count = 0
count_rem = 0
possible = False
for i in reversed(n):
	if count >= k:
		possible = True
		break
	elif i is '0':
		count += 1
	else:
		count_rem += 1
if possible:
	print(count_rem)
elif count is 0:
	print(len(n))
else:
	print(len(n) - 1)


from math import inf, sqrt, floor, ceil
from collections import Counter, defaultdict, deque
from heapq import heappush as hpush, heappop as hpop, heapify as h
from operator import itemgetter
from itertools import product
from bisect import bisect_left, bisect_right
(s, k) = map(int, input().split())
s = str(s)
if len(s) <= k:
	print(len(s) - 1)
else:
	(digit, ans) = (0, 0)
	for i in range(len(s) - 1, -1, -1):
		if digit == k:
			break
		if s[i] == '0':
			digit += 1
			continue
		else:
			ans += 1
	if ans == len(s) - s.count('0'):
		ans = len(s) - 1
	print(ans)


(n, k) = input().split()
k = 10 ** int(k)
a = len(n) - 1
s = 0
while int(n) % k != 0:
	for i in range(len(n) - 1, -1, -1):
		if n[i] != '0':
			n = n[:i] + n[i + 1:]
			s += 1
			break
print(a if set(list(n)) == {'0'} else s)


(n, k) = map(str, input().split())
z = n.count('0')
if z < int(k):
	print(len(n) - 1)
else:
	n = n[::-1]
	count = 0
	cnt = 0
	for i in n:
		if count == int(k):
			print(cnt)
			break
		elif i == '0':
			count += 1
		else:
			cnt += 1
	else:
		print(cnt)


(n, k) = map(int, input().split())
s = str(n)
l = []
for i in range(len(s)):
	l.append(int(s[i]))
a = l.count(0)
if a >= k:
	count = 0
	x = 0
	i = len(l)
	while i != 0:
		if count != k:
			if l[i - 1] != 0:
				x += 1
			else:
				count += 1
			i -= 1
		else:
			break
	print(x)
elif 0 in l:
	print(len(l) - 1)
else:
	print(len(l))


(n, k) = list(map(str, input().split()))
k = int(k)
n = n[::-1]
cc = 0
cz = 0
c = len(n)
for i in range(c):
	if int(n[i]) == 0:
		cz += 1
	elif cz >= k:
		break
	else:
		cc += 1
if cz < k:
	print(c - 1)
else:
	print(min(c - 1, cc))


(n, k) = input().split()
n = list(n)
st_len = len(n)
k = int(k)
res = 0
while k > 0 and n:
	if n[-1] == '0':
		k -= 1
	else:
		res += 1
	n.pop()
if n:
	print(res)
else:
	print(st_len - 1)


(n, k) = map(int, input().split())
if str(n).count('0') >= k and n != 0:
	x = str(n)[::-1]
	for l in range(1, len(x)):
		if x[:l].count('0') == k:
			print(l - k)
			break
else:
	print(len(str(n)) - 1)


(n, k) = map(int, input().split())
nLen = len(str(n))
if nLen < k + 1:
	print(nLen - 1)
	exit()
total = 0
zeros = 0
while zeros < k:
	digit = n % 10
	n //= 10
	total += 1 if digit != 0 else 0
	zeros += 1 if digit == 0 else 0
print(total if nLen - total > k else nLen - 1)


(n, k) = list(map(int, input().split()))
zeroes = 0
deletes = 0
good = False
for c in str(n)[::-1]:
	if c == '0':
		zeroes += 1
		if zeroes == k:
			good = True
			break
	else:
		deletes += 1
if good:
	print(deletes)
elif zeroes >= 1:
	print(len(str(n)) - 1)


x = input()
x = x.split()
a = int(x[0])
b = 10 ** int(x[1])
connumeros = 0
conceros = 0
k = 0
n = len(str(a))
while k < n and conceros <= int(x[1]):
	ultimo = a % 10
	if ultimo != 0:
		connumeros += 1
	else:
		conceros += 1
	if conceros == int(x[1]):
		break
	a = a // 10
	k += 1
if k == n:
	print(n - 1)
else:
	print(connumeros)


(n, m) = input().split()
m = int(m)
k = m
remove = 0
n = str(n)
for i in range(n.__len__() - 1, -1, -1):
	if k <= 0:
		break
	if n[i] == '0':
		k -= 1
	else:
		remove += 1
if m == k:
	print(n.__len__())
elif k > 0:
	print(n.__len__() - 1)
else:
	print(remove)


(n, k) = input().split()
k = int(k)
n = n[::-1]
s = 0
for c in n:
	if k == 0:
		break
	if c != '0':
		s += 1
	else:
		k -= 1
if k == 0:
	print(s)
else:
	print(len(n) - 1)


(n, m) = input().split()
k = int(m)
n = n[::-1]
e = 0
t = 0
for i in n:
	if t != k:
		if i != '0':
			e += 1
		elif i == '0':
			t += 1
	else:
		break
print(e if t == k else len(n) - 1)


(number, power) = list(map(str, input().split()))
pow = int(power)
answer = 0
count = 0
flag = 0
length = 0
if len(number) <= pow:
	pass
else:
	stri = number[::-1]
	length = len(stri)
	for i in stri:
		if count == pow:
			flag = 1
			break
		if i == '0':
			count += 1
		else:
			answer += 1
if flag == 1:
	print(answer)
else:
	print(len(number) - 1)


c = 1
cases = 1
while c <= cases:
	[n, k] = [int(i) for i in input().split()]
	cnt = 0
	rem = 0
	if n > 10 ** k:
		for i in str(n)[::-1]:
			if i == '0':
				cnt += 1
				if cnt == k:
					break
			else:
				rem += 1
		if cnt != k:
			rem = len(str(n)) - 1
	elif n < 10 ** k:
		rem = len(str(n)) - 1
	print(rem)
	c = c + 1


(n, k) = list(map(int, input().split()))
n = list(str(n))
a = len(n)
if n.count('0') < k:
	print(a - 1)
else:
	cz = 0
	ca = 0
	for i in n[::-1]:
		if i == '0':
			cz += 1
		else:
			ca += 1
		if cz == k:
			print(ca)
			break


a = input().split()
n = int(a[0])
k = int(a[1])
s = str(n)
len_ = len(s)
zeros = 0
nzeros = 0
flag = True
for i in range(len_ - 1, -1, -1):
	if s[i] == '0':
		zeros += 1
		if zeros == k:
			print(nzeros)
			flag = False
			break
	else:
		nzeros += 1
if flag:
	if zeros > 0:
		print(len_ - 1)
	else:
		print(len_)


(n, k) = map(int, input().split())
w = 0
while n % 10 ** k != 0:
	n = list(str(n))
	for index in range(len(n) - 1, -1, -1):
		digit = int(n[index])
		if digit != 0:
			w += 1
			del n[index]
			break
	if int(''.join(n)) == 0:
		w += len(n) - 1
		break
	else:
		n = int(''.join(n))
print(w)


(n, m) = map(str, input().split())
m = int(m)
length = len(n)
cnt = 0
ans = 0
for i in range(length - 1, -1, -1):
	if n[i] == '0':
		cnt += 1
	else:
		ans += 1
	if cnt == m:
		break
if cnt == m:
	print(ans)
else:
	if cnt > 1:
		ans += cnt - 1
	print(ans)


a = input()
a = a.split()
n = int(a[0])
k = int(a[1])
m = list(str(n))
m.reverse()
res = 0
cero = 0
ceros = 0
for r in m:
	if r == '0':
		ceros += 1
if ceros < k:
	res = len(str(n)) - 1
else:
	for j in m:
		if j != '0':
			res += 1
		else:
			cero += 1
			if cero == k:
				break
print(res)


(n, k) = list(map(int, input().split()))
a = str(n)
b = 0
d = 0
e = 0
for i in range(len(a) - 1, -1, -1):
	if a[i] == '0':
		b = b + 1
	else:
		d = d + 1
	if b == k:
		e = 1
		break
if e == 1:
	print(d)
else:
	print(len(a) - 1)


x = list(map(int, input().split()))
k = x[1]
nu = str(x[0])
l = len(nu)
re = 0
flag = False
for i in range(l):
	if k == 0:
		flag = True
		break
	elif nu[l - 1 - i] == '0':
		k = k - 1
	elif nu[l - 1 - i] != '0':
		re += 1
if flag:
	print(re)
else:
	print(re + (l - re - 1))


(n, k) = input().split()
k = int(k)
n = list(n)[::-1]
cnt0 = 0
ans = 0
cnt = 0
for x in n:
	if cnt0 == k:
		break
	cnt += 1
	if x == '0':
		cnt0 += 1
	else:
		ans += 1
if cnt0 == k and cnt < len(n):
	print(ans)
else:
	print(len(n) - 1)


(n, k) = input().split(' ')
k = int(k)
cur = 0
ans = 0
great = False
for c in reversed(n):
	if cur >= k:
		great = True
		break
	if c == '0':
		cur += 1
	else:
		ans += 1
if great:
	print(ans)
else:
	print(len(n) - 1)


(n, k) = input().strip().split()
k = int(k)
n = list(n)
(res, cnt) = (0, 0)
n.reverse()
for c in n:
	if c == '0':
		cnt += 1
	else:
		res += 1
	if cnt == k:
		break
print(res if cnt == k else len(n) - 1)


(a, b) = input().split(' ')
z_count = a.count('0')
if z_count < int(b) and z_count > 0:
	print(len(a) - 1)
else:
	a = a[-1::-1]
	z_count = 0
	nz_count = 0
	for c in a:
		if z_count == int(b):
			break
		if c == '0':
			z_count += 1
		else:
			nz_count += 1
	print(nz_count)
exit(0)


(a, b) = [int(i) for i in input().split()]
a = str(a)
c = a.count('0')
if c >= b:
	a = a[::-1]
	e = 0
	for i in range(0, len(a)):
		if a[i] == '0':
			e = e + 1
		if e == b:
			l = i
			break
	a = a[0:l]
	print(len(a) - a.count('0'))
else:
	print(len(a) - 1)


(n, k) = map(int, input().split())
ln = len(str(n))
c = 0
d = 0
b = 0
while n:
	y = n % 10
	if y:
		d += 1
	else:
		c += 1
	if c == k:
		b = 1
		break
	n //= 10
print(min(d, ln - 1) if b else ln - 1)


(s, k) = input().split()
k = int(k)
n = len(s)
ans = 0
cnt = 0
for i in range(n - 1, -1, -1):
	if cnt == k:
		print(ans)
		break
	elif s[i] == '0':
		cnt += 1
	else:
		ans += 1
else:
	print(n - 1)


(n, k) = map(int, input().split())
(ans, c) = (0, 0)
while k > 0 and n > 0:
	if n % 10 == 0:
		k -= 1
	else:
		ans += 1
	n //= 10
	c += 1
print(ans if n > 0 else max(0, c - 1))


(n, k) = map(int, input().split())
if n == 0:
	print(0)
else:
	a = []
	while n != 0:
		a.append(n % 10)
		n = n // 10
	c = 0
	z = 0
	x = 0
	g = 0
	q = 0
	for i in range(len(a)):
		if a[i] == 0:
			c += 1
		else:
			z += 1
	i = 0
	while g != k and i < len(a):
		if a[i] == 0:
			g += 1
		else:
			x += 1
		i += 1
	if x == z:
		print(len(a) - 1)
	else:
		print(x)


(n, k) = map(int, input().split(' '))
s = str(n)
s = s[::-1]
count = 0
res = 0
for i in range(len(s)):
	if s[i] == '0':
		count += 1
	else:
		res += 1
	if count == k:
		print(res)
		exit()
print(len(s) - 1)


(n, k) = input().split()
k = int(k)
c = v = 0
for u in n[::-1]:
	if u == '0':
		v += 1
	else:
		c += 1
	if v == k:
		break
print([c, len(n) - 1][v < k])


(n, k) = map(int, input().split())
n = str(n)
changes = 0
zeros = 0
for digit in n[::-1]:
	if zeros == k:
		break
	if digit == '0':
		zeros += 1
	else:
		changes += 1
if zeros != k:
	print(len(n) - 1)
else:
	print(changes)


(n, k) = [int(x) for x in input().split()]
digits = list(str(n))
zero_count = digits.count('0')
if zero_count < k:
	print(len(str(n)) - 1)
	exit()
count = 0
i = len(digits) - 1
while int(''.join(digits)) % 10 ** k > 0:
	if digits[i] != '0':
		del digits[i]
		count += 1
	i -= 1
print(count)


(n, k) = [str(j) for j in input().split()]
k = int(k)
zc = n.count('0')
if zc >= k and len(n) > zc:
	(count, zero_c) = (0, 0)
	for j in range(len(n) - 1, -1, -1):
		if n[j] == '0':
			zero_c += 1
			if zero_c == k:
				break
		else:
			count += 1
	print(count)
else:
	print(len(n) - 1)


(n, k) = map(int, input().split())
len_n = len(str(n))
if len_n < k + 1:
	print(len_n - 1)
else:
	n = str(n)
	mn = 0
	kol_nul = 0
	i = len_n - 1
	while i > -1:
		if kol_nul == k:
			break
		if n[i] == '0':
			kol_nul += 1
		else:
			mn += 1
		i -= 1
	else:
		mn = len_n - 1
	print(mn)


a = list(input().split())
n = a[0]
k = int(a[1])
c = 0
f = 0
for x in range(-1, -len(n) - 1, -1):
	if n[x] == '0':
		c = c + 1
		if c == k:
			print(-x - k)
			f = 1
			break
if f == 0:
	print(len(n) - 1)


(n, k) = map(int, input().split())
import sys
(number_of_digit, number_of_zero) = (0, 0)
for digit in str(n)[::-1]:
	if digit == '0':
		number_of_zero += 1
	else:
		number_of_digit += 1
	if number_of_zero >= k:
		print(number_of_digit)
		sys.exit()
print(len(str(n)) - 1)


(n, k) = [x for x in input().split()]
k = int(k)
zerocount = 0
for ch in n:
	if ch == '0':
		zerocount += 1
answer = -1
if zerocount < k:
	answer = len(n) - 1
else:
	zeronum = 0
	removenum = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			zeronum += 1
			if zeronum == k:
				answer = removenum
				break
		else:
			removenum += 1
print(answer)


(n, k) = map(str, input().split())
l = len(n) - 1
res = zero = 0
for i in range(l, -1, -1):
	if n[i] == '0':
		zero += 1
		if zero == int(k):
			break
	else:
		res += 1
if zero != int(k):
	print(l)
else:
	print(res)


tmp = input().split(' ')
a = tmp[0]
tempe = a
b = int(tmp[1])
ans = 0
while a != '' and b != 0:
	if a[-1] == '0':
		b -= 1
	else:
		ans += 1
	a = a[:-1]
if '0' in tempe:
	ans = min(ans, len(tempe) - 1)
if b == 0:
	print(ans)
else:
	print(len(tempe) - 1)


(number, k) = input().split(' ')
if len(number) <= int(k):
	print(len(number) - 1)
else:
	countZero = 0
	countDelete = 0
	for i in range(1, len(number) + 1):
		if countZero == int(k):
			break
		if number[-i] == '0':
			countZero += 1
		else:
			countDelete += 1
	if len(number) - countDelete < int(k) + 1:
		print(len(number) - 1)
	else:
		print(countDelete)


nk = list(map(int, input().split()))
n = str(nk[0])
k = nk[1]
nol = 0
ans = 0
l = n.count('0')
if l >= k:
	for i in range(len(n) - 1, 0, -1):
		if nol == k:
			break
		if int(n[i]) == 0:
			nol += 1
		else:
			ans += 1
else:
	ans = len(n) - 1
print(ans)


s = input().split()
k = int(s[1])
n = s[0]
ptr = len(s[0]) - 1
zerocount = 0
ans = 0
while ptr >= 0 and zerocount < k:
	if n[ptr] == '0':
		zerocount += 1
	else:
		ans += 1
	ptr -= 1
if ptr == -1:
	print(len(n) - 1)
else:
	print(ans)


import sys
fin = sys.stdin
fout = sys.stdout
(n, k) = fin.readline().split()
k = int(k)
k = 10 ** k
ans = 10 ** 9

def gen(cur, pos):
	global ans
	if pos == len(n):
		res = ''
		for i in range(len(n)):
			if not cur[i]:
				res += n[i]
		if len(res) > 0 and int(res) != 0 and (int(res) % k == 0):
			ans = min(ans, cur.count(True))
	else:
		cur[pos] = False
		gen(cur, pos + 1)
		cur[pos] = True
		gen(cur, pos + 1)
gen([False] * len(n), 0)
if '0' in set(list(n)):
	ans = min(ans, len(n) - 1)
fout.write(str(ans))


(n, k) = input().split()
k = int(k)
n = list(n)
i = len(n) - 1
count = 0
while i >= 0 and k > 0:
	if n[i] == '0':
		k -= 1
		i -= 1
	else:
		i -= 1
		count += 1
if i == -1:
	count = len(n) - 1
print(count)


import itertools
(N, K) = input().split()
K = int(K)
groups = itertools.groupby(N)
lst = []
for (key, vals) in groups:
	lst.append((key, len(list(vals))))
lst.reverse()
zero_cnt = 0
ans = 0
for l in lst:
	if zero_cnt >= K:
		print(ans)
		exit()
	if l[0] == '0':
		zero_cnt += l[1]
	else:
		ans += l[1]
print(len(N) - 1)


def solve(l):
	for i in range(5):
		if abs(l[i] & 1):
			return -1
	ans = 0
	for i in range(5):
		if l[i] > 0:
			ans += l[i] // 2
	return ans
(n, k) = map(int, input().split())
n = str(n)
ans = 0
for i in range(len(n)):
	if k <= 0:
		break
	if n[len(n) - i - 1] != '0':
		ans += 1
	else:
		k -= 1
if k <= 0:
	print(ans)
else:
	print(len(n) - 1)


(a, b) = map(int, input().split())
a = str(a)
a = a[::-1]
r = 0
c = 0
for i in a:
	if c < b:
		if i == '0':
			c += 1
		else:
			r += 1
if c == b:
	print(r)
else:
	print(len(a) - 1)


(s, k) = input().split()
k = int(k)
n = len(s)
z = 0
c = 0
for i in range(n - 1, -1, -1):
	if k == z:
		break
	if s[i] != '0':
		c += 1
	else:
		z += 1
if z < k:
	print(n - 1)
else:
	print(c)


def main():
	(n, k) = input().split()
	k = int(k)
	if len(n) <= k:
		print(len(n) - 1)
		return
	num_changes = 0
	pointer = len(n) - 1
	while k:
		if len(n) <= k or pointer < 0:
			print(len(n) - 1)
			return
		if n[pointer] is '0':
			k -= 1
		else:
			num_changes += 1
		pointer -= 1
	print(num_changes)
main()


st = input().strip().split(' ')
s = st[0]
k = int(st[1])
ans = 0
zc = 0
for i in range(len(s) - 1, -1, -1):
	if k > 0:
		if s[i] == '0':
			k -= 1
			zc += 1
		else:
			ans += 1
	else:
		break
if k > 0:
	print(len(s) - 1)
else:
	print(ans)


(a, b) = input().split()
b = int(b)
r = 0

def check(a, b):
	return a[-b:] == '0' * b
if check(a, b):
	print(0)
	exit(0)
for i in range(len(a) - 1, -1, -1):
	if a[i] != '0':
		a = a[:i] + a[i + 1:]
		r += 1
	if check(a, b):
		print(r)
		exit(0)
zeros = True
for i in a:
	if i != '0':
		zeros = False
if not zeros:
	print(r)
else:
	print(r + len(a) - 1)


(a, b) = map(int, input().split())
c = 0
c1 = 0
l = []
l = list(map(int, str(a)))
count = l.count(0)
le = len(l)
if b > count:
	print(le - 1)
else:
	for i in l[::-1]:
		if c == b:
			break
		if i == 0:
			c += 1
		else:
			c1 += 1
	print(c1)


(n, k) = input().split()
k = int(k)
cnt = 0
rem = 0
for i in n[::-1]:
	i = int(i)
	if i == 0:
		cnt += 1
	else:
		rem += 1
	if cnt == k:
		print(rem)
		break
if cnt < k:
	print(cnt + rem - 1)


(n, k) = input().split()
k = int(k)
l = len(n)
if l <= k:
	print(l - 1)
else:
	z = 0
	ans = 0
	for i in range(-1, -l, -1):
		if n[i] == '0':
			z += 1
			if z == k:
				exit(print(ans))
		else:
			ans += 1
	print(l - 1)


(n, k) = input().strip().split()
k = int(k)
if n.count('0') >= k:
	ans = 0
	zeros = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			zeros += 1
		if zeros == k:
			break
		if n[i] != '0':
			ans += 1
	print(ans)
else:
	print(len(n) - 1)


l = input().split()
k = int(l[1])
n = l[0]
n = n[::-1]

def compute():
	j = 0
	i = 0
	ans = 0
	if len(n) <= k:
		return len(n) - 1
	while j < k and i < len(n):
		if n[i] != '0':
			ans += 1
		else:
			j += 1
		i += 1
	if i == len(n) and j < k:
		return len(n) - 1
	else:
		return ans
print(compute())


(x, y) = input().split(' ')
if x.count('0') < int(y):
	print(len(x) - 1)
else:
	num_z = 0
	to_del = 0
	for j in x[::-1]:
		if num_z >= int(y):
			break
		elif j == '0':
			num_z += 1
		else:
			to_del += 1
	print(to_del)


(n, k) = map(int, input().split())
e = 10 ** k
str(n)
if int(n) < e:
	print(len(str(n)) - 1)
else:
	a = list(str(n))
	ans = 0
	iter = list(range(0, len(a)))
	iter.reverse()
	for i in iter:
		if a[i] == '0':
			ans += 1
	if ans < k:
		print(len(str(n)) - 1)
	else:
		q = 0
		w = 0
		for i in iter:
			if a[i] == '0':
				q += 1
			else:
				w += 1
			if q == k:
				print(w)
				break


(n, k) = input().split()
k = int(k)
l = len(n)
s = list(reversed(list(map(int, n))))
c = 0
n = 0
while c < k:
	try:
		if s[c] == 0:
			c += 1
		else:
			s.pop(c)
			n += 1
	except IndexError:
		break
if s[-1] == 0:
	print(l - 1)
else:
	print(n)


(a, k) = input().strip().split(' ')
a = list(a)
k = int(k)
h = 0
j = 0
x = a.count('0')
if x < k:
	print(len(a) - 1)
else:
	for i in range(len(a) - 1, -1, -1):
		if a[i] == '0':
			h += 1
		else:
			j += 1
		if h == k:
			print(j)
			break


(n, k) = map(int, input().split())
len_n = len(str(n))
n_str_rev = list(reversed(str(n)))
of_zeros = 0
deleted = 0
if 10 ** k > n or n_str_rev.count('0') < k:
	print(len(str(n)) - 1)
else:
	for i in range(len_n):
		if n_str_rev[i] == '0':
			of_zeros += 1
		else:
			deleted += 1
		if of_zeros == k:
			print(deleted)
			break


(n, k) = map(str, input().split())
k = int(k)
a = n.count('0')
cnt = 0
ans = 0
if int(n) % 10 ** k == 0:
	print(0)
elif len(n) <= len(str(10 ** k)):
	print(len(n) - 1)
else:
	i = len(n) - 1
	while cnt < k and i >= 0:
		if n[i] != '0':
			ans += 1
		else:
			cnt += 1
		i -= 1
	if ans + a == len(n):
		print(len(n) - 1)
	else:
		print(ans)


(a, b) = map(int, input().split())
a = list(str(a))
c = a.count('0')
if c < b:
	print(len(a) - 1)
else:
	a.reverse()
	t = b
	r = 0
	for i in a:
		if i == '0':
			t -= 1
			if t == 0:
				break
			continue
		r += 1
	print(r)


(N, K) = [n for n in input().split()]
K = int(K)
i = 0
dels = 0
for d in reversed(N):
	if i < K:
		if d != '0':
			dels += 1
			i -= 1
	else:
		break
	i += 1
l = len(N)
if i + dels == l or K >= l:
	print(len(N) - 1)
else:
	print(dels)


(var1, var2) = input().split()
var2 = int(var2)
var1 = var1[::-1]
k = 0
r = 0
for i in var1:
	if k == var2:
		break
	if i == '0':
		k += 1
	else:
		r += 1
print(r if k == var2 else max(0, len(var1) - 1))


def solve(n, k):

	def nums(s):
		return len([c for c in s if c != '0'])
	s = str(n)
	if len(s) - nums(s) < k:
		return len(s) - 1
	s = s[::-1]
	s = s[0:s.replace('0', 'x', k).rfind('x')]
	return nums(s)
print(solve(*[int(s) for s in input().split()]))


(n, k) = input().split()
k = int(k)
n = list(n)
ans = 0
zeros = 0
for i in n:
	if i == '0':
		zeros += 1
if zeros >= k:
	i = len(n) - 1
	while k:
		if n[i] == '0':
			k -= 1
		else:
			ans += 1
		i -= 1
	print(ans)
else:
	print(len(n) - 1)


(n, k) = input().split()
k = int(k)
l = len(n)
if l < k or n.count('0') < k:
	print(l - 1)
else:
	reverse = n[::-1]
	remove = 0
	z = 0
	for x in reverse:
		remove += x != '0'
		z += x == '0'
		if z == k:
			print(remove)
			break


[n, c] = [x for x in input().split()]
b = int(c)
z = 0
d = 0
if len(n) == 1:
	print(0)
else:
	for i in range(len(n)):
		if n[len(n) - i - 1] == '0':
			z += 1
			if z == b:
				print(d)
				break
		else:
			d += 1
			if i == len(n) - 1:
				print(len(n) - 1)
				break


from sys import maxsize, stdout, stdin, stderr
import re
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
(s, k) = S().split()
(k, n, s, c) = (int(k), len(s), list(s), 0)
cnt = 0
if s == '0':
	print(0)
for i in range(n - 1, -1, -1):
	if s[i] == '0':
		cnt += 1
	if cnt == k:
		print(n - i - k)
		exit()
print(n - 1)


[n, k] = list(map(int, input().split()))
s = str(n)
if n == 0:
	print(0)
	exit(0)
res = 0
zn = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == '0':
		zn += 1
	elif i > 0:
		res += 1
	else:
		print(len(s) - 1)
		exit(0)
	if zn == k:
		print(res)
		exit(0)


a = list(map(int, input().split()))
(n, k) = (a[0], a[1])
str1 = str(n)
if str1.count('0') < k:
	print(len(str(n)) - 1)
else:
	i = len(str1) - 1
	s = 0
	while int(str1) % 10 ** k != 0:
		if str1[i] == '0':
			i -= 1
		else:
			str1 = str1[:i] + str1[i + 1:]
			s += 1
			i -= 1
	print(s)


line = list(input().split())
k = int(line[1])
string = line[0]
cnt = 0
n = 0
b = False
for i in range(len(string) - 1, -1, -1):
	if string[i] != '0':
		cnt += 1
	else:
		n += 1
	if n == k:
		break
	if i == 0:
		b = True
if b:
	print(cnt + n - 1)
else:
	print(cnt)


import sys
import math
from sys import stdin, stdout
from collections import deque, defaultdict
from math import ceil, floor, inf, sqrt, factorial, gcd, log2
from copy import deepcopy
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
(n, k) = iia()
n = str(n)[::-1]
count = 0
subcount = 0
for i in n:
	if i == '0':
		count += 1
	else:
		subcount += 1
	if count == k:
		break
if count < k:
	print(len(n) - 1)
else:
	print(subcount)


(n, k) = input().split()
(i, j, k) = (0, 0, int(k))
for ch in n[::-1]:
	if ch == '0':
		i += 1
		if i == k:
			print(j)
			break
	else:
		j += 1
else:
	print(len(n) - 1)


def f():
	(n, k) = [int(i) for i in input().split()]
	n = str(n)
	ans = len(n) - 1
	m = 0
	moves = 0
	while n:
		if n[-1] == '0':
			m += 1
			if m == k:
				break
		else:
			moves += 1
		n = n[:-1]
	else:
		moves = float('inf')
	print(min(moves, ans))
f()


(m, k) = input().split()
(k, c, n) = (int(k), 0, 0)
if m == 0:
	print('0')
	exit()
for i in reversed(m):
	if i == '0':
		c += 1
	else:
		n += 1
	if c == k:
		break
else:
	print(len(m) - 1)
	exit()
print(n)


(n, k) = list(map(int, input().split()))
den = 10 ** k
if n % den == 0:
	print(0)
	exit()
n = str(n)
w = 0
for i in range(len(n) - 1, -1, -1):
	if n[i] != '0':
		w += 1
		n = n[:i] + n[i + 1:]
	if n.strip('0') == '':
		print(w + len(n) - 1)
		break
	if int(n) % den == 0:
		print(w)
		break


(num, k) = [x for x in input().split(' ')]

def main():
	(zeros, dropped) = (0, 0)
	for numb in num[::-1]:
		if zeros < int(k):
			if numb == '0':
				zeros += 1
			else:
				dropped += 1
		else:
			return dropped
	return len(num) - 1
print(main())


from sys import stdin, stdout

def ri():
	return map(int, input().split())
(n, k) = input().split()
k = int(k)
zcnt = 0
rcnt = 0
for i in range(len(n) - 1, 0, -1):
	if n[i] == '0':
		zcnt += 1
	else:
		rcnt += 1
	if zcnt == k:
		print(rcnt)
		exit()
print(len(n) - 1)


(number, exponent) = input().split(' ')
number = list(number)
exponent = int(exponent)
zeroFound = 0
removeCount = 0
number.reverse()
for x in number:
	if int(x) == 0:
		zeroFound += 1
		if zeroFound == exponent:
			break
	else:
		removeCount += 1
if zeroFound < exponent:
	removeCount = len(number) - 1
print(removeCount)


(n, k) = input().split()
k = int(k)
c = 0
t = len(n)
for i in range(t):
	if n[i] == '0':
		c += 1
if c < k:
	print(t - 1)
else:
	x = 0
	for i in range(1, t + 1):
		if n[-i] == '0':
			x += 1
		if x == k:
			print(i - x)
			break


(n, k) = [int(x) for x in input().split()]
t = 100
for x in range(len(str(n))):
	f = str(n)[-x - 1:]
	if f.count('0') == k:
		t = len(f) - f.count('0')
		break
print(min(t, len(str(n)) - 1))


(n, k) = map(int, input().split())
s = str(n)
x = s[::-1]
c = 0
ans = 0
for i in range(len(x)):
	if x[i] != '0':
		ans += 1
	else:
		c += 1
		if c == k:
			break
xv = 0
cc = 0
for i in range(len(s)):
	if s[i] == '0':
		xv += 1
	else:
		cc += 1
if xv < k:
	print(len(s) - 1)
	exit()
print(ans)


(n, k) = map(int, input().split())
k = 10 ** k
r = str(n)
i = len(r) - 1
c = 0
while 1:
	if int(r) % k == 0 or len(r) - r.count('0') == 1:
		break
	if r[i] != '0':
		r = r[:i] + r[i + 1:]
		c += 1
	i -= 1
if int(r) < k:
	print(len(str(n)) - 1)
else:
	print(c)


(n, k) = input().split()
k = int(k)
cnt = 0
for i in n:
	if i == '0':
		cnt += 1
if cnt < k:
	print(len(n) - 1)
else:
	p = 0
	ans = 0
	i = len(n) - 1
	while ans < k:
		if n[i] == '0':
			ans += 1
		else:
			p += 1
		i -= 1
	print(p)


def main():
	(n, k) = input().split()
	k = int(k)
	l = len(n)
	i = l - 1
	zeros = 0
	ans = 0
	while i >= 0:
		if n[i] == '0':
			zeros += 1
		else:
			ans += 1
		i -= 1
		if zeros == k:
			print(ans)
			return
	print(l - 1)
main()


(n, k) = map(int, input().split())
n = str(n)
cnt = 0
if n == '0':
	print(0)
	exit()
ans = 0
for i in range(len(n) - 1, -1, -1):
	if cnt == k:
		print(ans)
		exit()
	elif n[i] != '0':
		ans += 1
	else:
		cnt += 1
print(len(n) - 1)


(n, k) = input().split()
k = int(k)
ans = 0
count = 0
for num in n[::-1]:
	if count == k:
		print(ans)
		exit()
	if num == '0':
		count += 1
	if num != '0':
		ans += 1
print(ans + count - 1)


s = input().split()
k = int(s[1])
s = s[0]
if s.count('0') < k:
	if s.count('0') > 0:
		print(len(s) - 1)
	else:
		print(len(s))
	return
have = 0
its = 0
for i in range(len(s) - 1, -1, -1):
	its += 1
	if s[i] == '0':
		have += 1
	if have == k:
		print(its - have)
		return


(n, k) = input().split()
k = int(k)

def isDivide(n, k):
	ln = len(n)
	numZero = 0
	for i in range(ln - 1, -1, -1):
		if n[i] != '0':
			break
		numZero += 1
	return numZero >= k or numZero == ln
lst = list(n)
steps = 0
i = 0
while not isDivide(''.join(lst), k):
	for i in range(len(lst) - 1, -1, -1):
		if lst[i] == '0':
			continue
		del lst[i]
		break
	steps += 1
if ''.join(lst) == '0' * len(lst):
	steps += len(lst) - 1
print(steps)


(n, k) = map(int, input().split())
n = list(repr(n))
x = 0
for i in range(len(n) - 1, -1, -1):
	if k == 0:
		break
	elif n[i] == '0':
		k -= 1
	else:
		x += 1
if k:
	print(len(n) - 1)
else:
	print(x)


(a, k) = input().split()
k = int(k)
start = -1
for j in range(len(a)):
	if a[j] != '0':
		start = j
		break
ans = 0
for j in range(len(a) - 1, j, -1):
	if k != 0:
		if a[j] == '0':
			k -= 1
		else:
			ans += 1
	else:
		break
if k == 0:
	print(ans)
else:
	print(len(a) - 1)


from sys import stdin, stdout
(s, k) = stdin.readline().split()
k = int(k)
ans = 0
cnt = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] != '0':
		ans += 1
	elif s[:i + 1].count('0') != len(s[:i + 1]):
		cnt += 1
	if cnt == k:
		stdout.write(str(ans))
		break
else:
	stdout.write(str(len(s) - 1))


(n, k) = map(int, input().split())
n = list(str(n))
counter = 0
zero_counter = 0
if n.count('0') >= k:
	for i in range(len(n) - 1, -1, -1):
		if n[i] != '0':
			counter += 1
		if n[i] == '0':
			zero_counter += 1
		if zero_counter == k:
			break
	print(counter)
else:
	print(len(n) - 1)


(n, k) = map(int, input().split())
c = 0
z = 0
if n == 0:
	print(0)
else:
	while z != k and n != 0:
		if n % 10 == 0:
			z += 1
		c += 1
		n = n // 10
	if z == k:
		print(c - k)
	else:
		print(c - 1)


arr = list(map(int, input().split()))
n = str(arr[0])
k = arr[1]
s = ''
zer_kolvo = 0
count = 0
s_s = n
if k >= len(n):
	print(len(n) - 1)
elif n.count('0') < k:
	print(len(n) - 1)
else:
	sch = 0
	n_c = n[::-1]
	for i in n_c:
		if i != '0':
			s_s = n[0:len(n) - sch]
			count += 1
		else:
			s_s = n[0:len(n) - sch] + '0' * zer_kolvo
			zer_kolvo += 1
		sch += 1
		if int(s_s) % 10 ** k == 0:
			print(count)
			break


(n, k) = input().split()
(n, k) = (n[::-1], int(k))
r = 0
for i in range(len(n)):
	if n[i] != '0':
		r += 1
	if i - r + 1 == k:
		break
else:
	r = len(n) - 1
print(r)


(n, k) = map(str, input().split())
num = int(n)
nd = int(len(n))
ans = int(1000000000.0)
for i in range(2 ** nd):
	tmp = '0'
	for j in range(nd):
		if i & 1 << j:
			tmp += n[j]
	ntmp = int(tmp[0:])
	kk = 10 ** int(k)
	if ntmp != 0 and ntmp % kk == 0:
		ans = min(ans, len(n) - len(tmp[1:]))
	if ntmp % kk == 0 and ntmp == 0:
		ans = min(ans, len(n) - 1)
print(ans)


import sys
(n, k) = list(map(int, input().split()))
num = list(reversed(str(n)))
ans = 0
zeros = 0
if num.count('0') < k:
	print(len(num) - 1)
	return
for ch in num:
	if ch == '0':
		zeros += 1
		if zeros == k:
			break
		continue
	ans += 1
print(ans)


x = input()
x = x.split()
N = int(x[0])
K = int(x[1])
ceros = 0
aux = 0
if K >= len(x[0]):
	print(len(x[0]) - 1)
else:
	while ceros < K:
		if N % 10 == 0:
			ceros += 1
		else:
			aux += 1
		N = N // 10
		if N == 0:
			print(len(x[0]) - 1)
			ceros = K + 1
	if ceros <= K:
		print(aux)


import sys
import math
from collections import OrderedDict

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
(n, k) = map(str, input().split())
if n == '0':
	print('0')
elif n.count('0') < int(k):
	print(len(n) - 1)
else:
	for i in range(1, len(n)):
		if n[i] == '0' and n[i:].count('0') == int(k):
			print(len(n[i:]) - int(k))
			break


(n, k) = input().split()
k = int(k)
raiseto = 10 ** k
number = int(n)
tempnumber = number
newstr = n
tempk = 10
ans = 0
countzero = 0
if tempnumber == 0:
	countzero = 1
else:
	while tempnumber > 0:
		if tempnumber % 10 == 0:
			countzero += 1
		tempnumber = tempnumber // 10
while tempk <= raiseto and number >= 0:
	if number % tempk == 0:
		tempk = tempk * 10
		continue
	elif tempk == 10:
		number = number // tempk
		ans += 1
		continue
	else:
		number = number // tempk * (tempk // 10)
		ans += 1
if number == 0:
	print(ans + countzero - 1)
else:
	print(ans)


def solve(n, i):
	removed = 0
	zero = 0
	for x in n[::-1]:
		if zero == i:
			return removed
		if x != '0':
			removed += 1
		else:
			zero += 1
	return zero - 1 + removed
(n, i) = input().split()
print(solve(n, int(i)))


(n, k) = input().split()
k = int(k)
ans = 0
nz = 0
for c in reversed(n):
	if nz == k:
		break
	if c == '0':
		nz += 1
	else:
		ans += 1
else:
	ans = len(n) - 1
print(ans)


(s, k) = input().split()
k = int(k)
n = len(s)
tot = 0
count = 0
for i in range(n - 1, -1, -1):
	if s[i] == '0':
		tot += 1
	else:
		count += 1
	if tot == k:
		print(count)
		break
else:
	print(len(s) - 1)


(x, k) = map(str, input().split())
k = int(k)
x = list(x)
z = pow(10, k)
x.reverse()
m = 0
l = x.count('0')
if l == 0:
	print(len(x))
elif l > 0 and l < k:
	print(len(x) - 1)
else:
	for i in range(len(x)):
		if x[i] == '0':
			m += 1
			if m == k:
				s = i
				break
	print(i - k + 1)


(n, k) = input().split()
k = int(k)
l = [len(n) - 1, 0] if n.count('0') < k else [0, -k, *n]
while l[1]:
	l[l.pop() == '0'] += 1
print(l[0])


(num, d) = input().split()
d = int(d)
count = 0
res = 0
if num.count('0') < d:
	print(len(num) - 1)
else:
	index = num[::-1].replace('0', '1', d - 1).find('0')
	print(index - d + 1)


(n, k) = list(map(int, input().split()))
ans = cnt = 0
while k and n:
	if n % 10 == 0:
		k -= 1
	else:
		ans += 1
	n //= 10
	cnt += 1
if n > 0:
	print(ans)
else:
	print(max(0, cnt - 1))


(s, k) = input().split()
k = int(k)
if s == '0':
	print(0)
elif s.count('0') < k:
	print(len(s) - 1)
else:
	s = s[::-1]
	cnt = 0
	for x in s:
		if k == 0:
			break
		if x == '0':
			k -= 1
		else:
			cnt += 1
	print(cnt)


(N, K) = list(map(int, input().split()))
(ans, cnt) = (0, 0)
while K and N:
	if N % 10 == 0:
		K -= 1
	else:
		ans += 1
	N //= 10
	cnt += 1
if N:
	print(ans)
else:
	print(max(0, cnt - 1))


from collections import Counter

def count_delete_digits(n, k):
	if n == 0:
		return 0
	n_str = str(n)
	length = len(n_str)
	if k >= length:
		if '0' in n_str:
			return length - 1
		else:
			return length
	if '0' not in n_str:
		return length
	if k > Counter(n_str)['0']:
		return length - 1
	deletes = 0
	zeros = 0
	for character in n_str[::-1]:
		if character == '0':
			zeros += 1
			if zeros == k:
				return deletes
		else:
			deletes += 1

def main():
	(n, k) = map(int, input().strip().split())
	print(count_delete_digits(n, k))
main()


from sys import stdin
(n, k) = stdin.readline().split()
l = len(n)
k = int(k)
c = cnt = 0
for i in range(l - 1, 0, -1):
	if n[i] == '0':
		c += 1
		if c == k:
			break
	else:
		cnt += 1
if l <= k and c > 0 or c < k:
	cnt = l - 1
print(cnt)


(n, k) = input().split(' ')
k = int(k)
if len(n) <= k:
	print(len(n) - 1)
else:
	ans = 0
	for x in n[::-1]:
		if x == '0':
			k = k - 1
		else:
			ans = ans + 1
		if k == 0:
			break
	if k == 0:
		print(ans)
	else:
		print(len(n) - 1)


(n, k) = input().split()
k = int(k)
n_z = 0
d = 0
for i in range(len(n)):
	if n[len(n) - i - 1] == '0':
		n_z += 1
		if n_z == k:
			print(d)
			quit()
	else:
		d += 1
print(len(n) - 1)


(m, k) = input().split()
c = 0
for i in range(-1, -1 * len(m), -1):
	if m[i] == '0':
		c += 1
	if c == int(k):
		break
print(-1 * i - c if c == int(k) else len(m) - 1)


(a, b) = input().split(' ')
h = list(a)
b = int(b)
u = 0
if a == '0':
	print(0)
elif b + 1 > len(a):
	if '0' in a:
		print(len(a) - 1)
	else:
		print(len(a))
else:
	z = 0
	while b:
		if len(h) > 0:
			if h[-1] == '0':
				b -= 1
				h.pop()
			else:
				u += 1
				h.pop()
		else:
			z += 1
			break
	if z > 0:
		if '0' in a:
			print(len(a) - 1)
		else:
			print(len(a))
	else:
		print(u)


inp = input().split()
s = inp[0]
k = int(inp[1])
ans = 0
i = len(s) - 1
while i >= 0 and k > 0:
	if s[i] != '0':
		ans = ans + 1
	else:
		k = k - 1
	i = i - 1
if k == 0:
	print(ans)
elif '0' in s:
	print(len(s) - 1)


import sys
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
(n, k) = li()
st = []
sn = str(n)[::-1]
zc = 0
dc = 0
for i in sn:
	if i == '0':
		zc += 1
		st.append(i)
	elif zc < k:
		dc += 1
	else:
		st.append(i)
fn = int(''.join(st)[::-1])
if fn == 0:
	dc += len(st) - 1
print(dc)


(n, k) = map(int, input().split())
n = str(n)
if n.count('0') < k:
	print(len(n) - 1)
else:
	(number_of_digit, number_of_zero) = (0, 0)
	for digit in str(n)[::-1]:
		if digit == '0':
			number_of_zero += 1
		else:
			number_of_digit += 1
		if number_of_zero >= k:
			print(number_of_digit)
			break


(n, k) = input().split(' ')
k = int(k)
zeros = 0
i = 0
nn = list(n)
while len(nn) > 0:
	a = nn.pop(-1)
	if a == '0':
		zeros += 1
	else:
		i += 1
	if zeros == k:
		print(i)
		break
	if len(nn) == 0:
		i += zeros - 1
		print(i)
		break


p = input().rstrip().split(' ')
x = list(p[0])
y = int(p[1])
B = 0
G = 0
for i in range(len(x) - 1, -1, -1):
	if y != 0:
		if x[i] == '0':
			y -= 1
		else:
			B += 1
	else:
		G = 1
		break
if G == 1:
	print(B)
else:
	print(len(x) - 1)


(n, k) = input().split()
k = int(k)
if n.count('0') < k:
	print(len(n) - 1)
else:
	cnt = 0
	zcnt = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			zcnt += 1
		else:
			cnt += 1
		if zcnt == k:
			print(cnt)
			break


(n, k) = map(int, input().split())
k0 = 0
k1 = 0
s = str(n)
for i in range(len(s) - 1, -1, -1):
	if s[i] == '0':
		k0 += 1
	else:
		k1 += 1
	if k0 == k:
		print(k1)
		break
if k > k0:
	print(len(s) - 1)


import sys
(n, k) = map(int, input().split())
n = str(n)
if n.count('0') >= k:
	p = len(n) - 1
	ctr = 0
	dell = 0
	while p >= 0:
		if ctr == k:
			break
		if n[p] == '0':
			ctr += 1
		else:
			dell += 1
		p -= 1
	print(dell)
else:
	print(len(n) - 1)


(n, k) = map(int, input().split())
n = list(str(n))
c = 0
if len(n) > k and n.count('0') >= k:
	while n[len(n) - k:] != ['0'] * k:
		for i in range(len(n) - 1, len(n) - k - 1, -1):
			if n[i] != '0':
				del n[i]
				c += 1
elif len(n) <= k or n.count('0') < k:
	c = len(n) - 1
print(c)


y = input().split()
x = int(y[1])
x1 = int(y[0])
x2 = list(y[0])
s = 0
z = 0
if x1 / 10 ** x < 1:
	s = len(y[0]) - 1
elif int(x1 / 10 ** x) == x1 / 10 ** x:
	s = 0
else:
	for i in range(len(y[0]) - 1, -1, -1):
		if z == x:
			break
		elif y[0][i] == '0':
			z += 1
		else:
			s += 1
			del x2[i]
	if len(x2) > 1 and x2[0] == '0':
		s += len(x2) - 1
print(s)


(x, y) = input().split()
y1 = int(y)
count = 0
count1 = 0
for i in range(len(x) - 1, -1, -1):
	if x[i] == '0':
		count += 1
		if count == y1:
			break
	else:
		count1 += 1
if count != y1 and count != 0:
	count1 = len(x) - 1
elif count == 0:
	count1 = len(x)
print(count1)


(num, k) = input().split()
k = int(k)
num = list(map(int, num))
num = num[::-1]
if num.count(0) >= k:
	c0 = 0
	g = 0
	for n in num:
		if n == 0:
			c0 += 1
		else:
			g += 1
		if c0 == k:
			break
	print(g)
elif 0 in num:
	print(len(num) - 1)
else:
	print(len(num))


(s, n) = input().split()
div = int('1' + '0' * int(n))
x = len(s) - 1
count = 0
ans = len(s) - 1
while x >= 0:
	if int(s) % div == 0:
		ans = count
		break
	if s[x] != '0':
		s = s[:x] + s[x + 1:]
		count += 1
	x -= 1
print(ans)


entrada = input().split()
dig = 0
zero = 0
if entrada[0].count('0') >= int(entrada[1]):
	for i in range(1, len(entrada[0])):
		if int(entrada[0][-i]) != 0:
			dig += 1
		else:
			zero += 1
			if zero == int(entrada[1]):
				break
	print(dig)
else:
	print(len(entrada[0]) - 1)


import math
(num, power) = map(int, input().split())
if num == 0:
	length = 1
else:
	length = math.floor(math.log10(num) + 1)
zero = 0
eliminate = 0
num = str(num)
for each in range(length - 1, -1, -1):
	if zero == power:
		break
	if each == 0 and zero > 0:
		eliminate = length - 1
		break
	if num[each] == '0':
		zero += 1
	else:
		eliminate += 1
if num == 0:
	print(0)
else:
	print(eliminate)


s = input().split()
n = s[0]
k = int(s[1])
ans = 0
cur = 0
for i in n[::-1]:
	if i == '0':
		cur += 1
	elif cur < k:
		ans += 1
if n.count('0') < k:
	if n.count('0') > 0:
		print(len(n) - 1)
	else:
		print(len(n))
else:
	print(ans)


def mult_mat(M1, M2):
	a11 = M1[0][0] * M2[0][0] + M1[0][1] * M2[1][0]
	a12 = M1[0][0] * M2[0][1] + M1[0][1] * M2[1][1]
	a21 = M1[1][0] * M2[0][0] + M1[1][1] * M2[1][0]
	a22 = M1[1][0] * M2[0][1] + M1[1][1] * M2[1][1]
	r = [[a11, a12], [a21, a22]]
	return r

def binpow(a, n):
	rez = [[a[0][0], a[0][1]], [a[1][0], a[1][1]]]
	s = bin(n)[3:]
	for i in s:
		rez = mult_mat(rez, rez)
		if i == '1':
			rez = mult_mat(rez, a)
	return rez[0][0]

def main():
	QWE = 'river'
	INF = 10 ** 18 + 9
	EPS = 10 ** (-9)
	import sys, math, re, urllib.request
	(n, m) = input().split(' ', 1)
	(n, m) = (n[::-1], int(m))
	cnt = 0
	rez = 0
	for i in n:
		if i == '0':
			cnt += 1
		else:
			rez += 1
		if cnt == m and cnt + rez != len(n):
			print(rez)
			return
	print(len(n) - 1)
main()


(n, k) = input().split()
k = int(k)
n = list(map(int, list(n)))
l = len(n)
j = l - 1
while j > -1 and k > 0:
	if n[j] != 0:
		del n[j]
	else:
		k -= 1
	j -= 1
if n[0] == 0:
	print(l - 1)
else:
	print(l - len(n))


(n, k) = map(int, input().split())
if n == 0:
	print(0)
	exit()
x = []
while n > 0:
	x.append(n % 10)
	n = n // 10
c1 = 0
c2 = 0
for i in range(len(x)):
	if x[i] == 0:
		c1 += 1
	if c1 == k:
		break
	if x[i] != 0:
		c2 += 1
if c1 < k:
	print(len(x) - 1)
else:
	print(c2)


(n, k) = input().split()
k = int(k)
count = 0
index = 0
for (i, x) in enumerate(reversed(n)):
	if x == '0':
		index = i
		count += 1
		if count == k:
			break
if len(n) < k + 1 or n.count('0') < k:
	print(len(n) - 1)
else:
	print(index + 1 - k)


(n, k) = [int(i) for i in input().split(' ')]
s = str(n)
l = len(s)
c = 0
ans = 0
i = l - 1
if l <= k or s.count('0') < k:
	print(l - 1)
else:
	while c < k and i > 0:
		if s[i] == '0':
			c += 1
		else:
			ans += 1
		i -= 1
	print(ans)


(n, k) = map(int, input().split())
p = n % 10 ** k
if n >= 10 ** k:
	s = str(n)
	c1 = 0
	c2 = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '0':
			c1 += 1
		if c1 >= k:
			break
		elif s[i] != '0':
			c2 += 1
	if c1 >= k:
		print(c2)
	else:
		print(len(s) - 1)
else:
	s = str(n)
	print(len(s) - 1)


(s, k) = input().split()
k = int(k)
i = -1
count = 0
while k > 0:
	try:
		if s[i] == '0':
			k -= 1
			i -= 1
		else:
			i -= 1
			count += 1
	except:
		if '0' in s:
			count = len(s) - 1
		else:
			count = len(s)
		break
print(count)


(a, b) = list(map(int, input().split()))
st = str(a)
if st.count('0') < b:
	print(len(st) - 1)
else:
	ans = 0
	cnt = 0
	st = st[::-1]
	for i in range(len(st)):
		if st[i] == '0':
			cnt += 1
			if cnt == b:
				break
		else:
			ans += 1
	print(ans)


(n, k) = map(int, input().split())
s = str(n)
k1 = k
s1 = s
ans = ''
res = 0
while k1 > 0:
	if len(s1) > 0 and s1[-1] != '0':
		res += 1
	else:
		k1 -= 1
	if len(s1) > 0:
		s1 = s1[:-1]
if len(s1) > 0:
	print(res)
else:
	print(len(s) - 1)


(n, k) = map(int, input().split())
s = str(n)
if s.count('0') < k:
	print(len(s) - 1)
else:
	z = 0
	i = len(s) - 1
	while z != k:
		if s[i] == '0':
			z += 1
		i -= 1
	s1 = s[:i + 1] + '0' * z
	print(len(s) - len(s1))


(n, k) = map(str, input().split())
k = int(k)
n = list(n)
if k > n.count('0'):
	print(len(n) - 1)
else:
	m = n[::-1].index('0')
	for i in range(k - 1):
		m = n[::-1].index('0', m + 1)
	print(m + 1 - k)


(n, k) = map(int, input().split())
n = str(n)
cnt = 0
if n.count('0') >= k:
	i = 1
	while cnt != k:
		if n[-i] == '0':
			cnt += 1
		if cnt == k:
			break
		i += 1
	print(i - cnt)
else:
	print(len(n) - 1)


(n, k) = input().split()
k = int(k)
current_nulls = 0
current = 0
for letter in n[::-1]:
	if letter == '0':
		current_nulls += 1
	else:
		current += 1
	if current_nulls == k:
		print(current)
		break
else:
	print(len(n) - 1)


import sys
import math
(n, k) = map(int, sys.stdin.readline().split())
sn = '%d' % n
m = int(math.pow(10, k))
count1 = 0
count2 = 0
if n % m == 0:
	print(0)
elif n < m:
	print(len(sn) - 1)
else:
	for i in range(len(sn) - 1, -1, -1):
		if sn[i] == '0':
			count1 += 1
		else:
			count2 += 1
		if count1 == k:
			print(count2)
			break
	else:
		print(len(sn) - 1)


import math
(n, k) = map(int, input().strip().split(' '))
temp = n
if n % 10 ** k == 0:
	print(0)
elif n // 10 ** k == 0:
	s = str(n)
	print(len(s) - 1)
else:
	c = 0
	while k > 0 and n > 0:
		if n % 10 != 0:
			n = n // 10
			c += 1
		else:
			k -= 1
			n = n // 10
	if k != 0:
		s = str(temp)
		print(len(s) - 1)
	else:
		print(c)


inp = input()
(n, kk) = inp.split(' ')
k = int(kk)
zeros = 0
dls = 0
i = len(n) - 1
while zeros < k:
	if i == -1:
		print(len(n) - 1)
		break
	if n[i] == '0':
		zeros += 1
	else:
		dls += 1
	i -= 1
	if zeros == k:
		print(dls)


(n, k) = [int(i) for i in input().split()]
strN = str(n)
removedDigits = 0

def floatInt(num):
	if num % 1 > 0:
		return float
	else:
		return int
if n / 10 ** k < 1:
	lnStrN = len(strN)
	zeros = strN.count('0')
	if zeros > 1:
		removed0 = zeros - 1
	else:
		removed0 = 0
	print(lnStrN - zeros + removed0)
else:
	while floatInt(n / 10 ** k) == float:
		inv = strN[::-1]
		for i in inv:
			if int(i) in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
				inv = inv.replace(i, '', True)
				removedDigits += 1
				strN = inv[::-1]
				if strN == '':
					n = 0
					break
				n = int(strN)
				break
	if len(strN) > 1 and n == 0:
		removedDigits += len(strN) - 1
	print(removedDigits)


(num, n) = input().split()
n = int(n)
i = len(num) - 1
j = 0
tot = 0
while i >= 0 and j < n:
	if num[i] == '0':
		j += 1
	else:
		tot += 1
	i -= 1
if j == n:
	print(tot)
else:
	print(len(num) - 1)


[n, k] = [int(i) for i in input().split()]
n = str(n)
if list(n).count('0') < k:
	print(len(n) - 1)
	exit(0)
count0 = 0
era = 0
for i in range(len(n)):
	if n[len(n) - 1 - i] == '0':
		count0 += 1
		if count0 == k:
			print(era)
			break
	else:
		era += 1


def solve(n, m):
	count = 0
	s = str(n)
	if len(s) <= m:
		if n % 10 ** m == 0:
			return 0
		else:
			return len(s) - 1
	i = 1
	while len(s) > m and int(s) % 10 ** m != 0:
		if s[-i] != '0':
			s = s[:len(s) - i] + s[len(s) - i + 1:]
			count += 1
		else:
			i += 1
	if len(s) >= m and int(s) % 10 ** m == 0:
		return count
	else:
		return len(str(n)) - 1
(n, m) = map(int, input().split())
print(solve(n, m))


(n, k) = map(int, input().split())
s = str(n)
s = s[::-1]
c = 0
d = 0
for i in range(len(s)):
	if c == k:
		break
	if s[i] == '0':
		c += 1
	elif s[i] != '0':
		d += 1
if len(s) <= k and c != 0:
	print(len(s) - 1)
elif c < k:
	print(len(s) - 1)
else:
	print(d)


X = list(input().split())
if X[0].count('0') < int(X[1]):
	print(len(X[0]) - 1)
	exit()
(Deleted, Need) = (0, int(X[1]))
i = len(X[0]) - 1
while Need != 0:
	if X[0][i] == '0':
		Need -= 1
	else:
		Deleted += 1
	i -= 1
print(Deleted)


import sys
(n, k) = input().split()
k = int(k)
cnt = cnt_zero = no = 0
if len(n) < k and '0' in n:
	print(len(n) - 1)
else:
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			cnt_zero += 1
		else:
			if i == 0 and k > cnt_zero:
				no = 1
			if k > cnt_zero:
				cnt += 1
	if no == 0:
		print(cnt)
	else:
		print(len(n) - 1)


def LI():
	return list(map(int, input().split()))

def II():
	return int(input())

def LS():
	return input().split()

def S():
	return input()

def n(lil):
	for i in range(len(lil), -1, -1):
		if lil[i - 1] != '0':
			return lil[:i - 1] + lil[i:]
li = input().split()
k = 0
while True:
	if int(li[0]) % 10 ** int(li[1]) != 0:
		li[0] = n(li[0])
		k += 1
		continue
	else:
		if li[0] == '0' * len(li[0]):
			k += len(li[0]) - 1
		break
print(int(k))


(number, k) = input().split()
k = int(k)
if number.count('0') < k:
	print(len(number) - 1)
else:
	list_of_zeros = []
	for i in range(len(number)):
		if number[-i - 1] == '0':
			list_of_zeros.append(-i - 1)
	answer = len(number) - number.rfind('0') - 1
	for i in range(k - 1):
		answer += list_of_zeros[i] - list_of_zeros[i + 1] - 1
	print(answer)


import sys, heapq
(n, k) = sys.stdin.readline().split()
if n == '0':
	print(0)
elif len(n) == 1:
	print(1)
else:
	cnt = 0
	z_cnt = 0
	if n.count('0') < int(k):
		print(len(n) - 1)
	else:
		for i in range(len(n) - 1, -1, -1):
			if z_cnt >= int(k):
				break
			if n[i] != '0':
				cnt += 1
			else:
				z_cnt += 1
		print(cnt)


(s, k) = input().split()
k = int(k)
N = len(s)
s = s[::-1]
n1 = 0
n2 = 0
l = float('inf')
for i in range(N):
	if s[i] == '0':
		n1 += 1
		if n1 == k:
			l = n2
	else:
		n2 += 1
print(min(l, N - 1))


(a, b) = map(int, input().split())
s = list(map(int, str(a)))
if len(s) <= b:
	print(len(s) - 1)
elif s.count(0) < b:
	print(len(s) - 1)
else:
	z = s[::-1]
	l = 0
	p = 0
	for n in z:
		if l == b:
			break
		elif n == 0:
			l += 1
		else:
			p += 1
	print(p)


inp = input()
data = inp.split()
n = int(data[0])
k = int(data[1])

def allZero(s):
	for i in s:
		if i != '0':
			return False
	return True

def removeChar(s, n):
	return s[:n] + s[n + 1:]
nStr = data[0]
zeros = 0
for char in nStr:
	if char == '0':
		zeros += 1
if nStr == '0':
	print(0)
elif zeros < k:
	print(len(nStr) - 1)
else:
	failed = True
	cuts = 0
	while failed:
		failed = False
		jj = 0
		for i in range(len(nStr) - 1, -1, -1):
			if nStr[i] == '0':
				jj += 1
			else:
				failed = True
				cuts += 1
				nStr = removeChar(nStr, i)
			if jj >= k:
				failed = False
				break
	print(cuts)


(n, k) = [int(x) for x in input().split()]
s = str(n)
ans = 0
nulls = 0
f = False
for i in range(len(s) - 1, -1, -1):
	if s[i] != '0':
		ans += 1
	else:
		nulls += 1
	if k == nulls:
		f = True
		ans = len(s) - i - nulls
		break
if f:
	print(ans)
else:
	print(len(s) - 1)


import sys

def make_gen(str):
	arr = str.split(' ')
	for item in arr:
		yield item
s = input()
s = make_gen(s)
n = next(s)
k = int(next(s))
count = 0
deleted = 0
for i in range(0, len(n)):
	if n[-i - 1] == '0':
		count += 1
		if count == k:
			break
	else:
		deleted += 1
if count < k:
	if count > 0:
		print(len(n) - 1)
	else:
		print(len(n))
else:
	print(deleted)


(s, k) = input().split()
s = list(s)
p = len(s)
k = int(k)
if p <= k:
	print(p - 1)
else:
	t = 0
	j = p - 1
	while k != 0 and j != -1:
		if s[j] != '0':
			t += 1
		else:
			k -= 1
		j -= 1
	if j == -1:
		print(p - 1)
	else:
		print(t)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, k) = M()
s = str(n)
if s.count('0') >= k:
	z = 0
	c = 0
	i = len(s) - 1
	while z != k:
		if s[i] == '0':
			z += 1
		else:
			c += 1
		i -= 1
	print(c)
else:
	print(len(s) - 1)


(n, k) = list(map(int, input().split()))
ns = list(str(n))
ns.reverse()
j = 0
i = 0
r = 0
try:
	while True:
		if j == k:
			break
		if ns[i] != '0':
			r += 1
		elif ns[i] == '0':
			j += 1
		i += 1
	ns.reverse()
	print(r)
except:
	print(len(ns) - 1)


(n, k) = map(int, input().split())
power = 10 ** k
if n == power:
	print(0)
elif n < power:
	n = str(n)
	print(len(n) - 1)
else:
	countothers = 0
	countzero = 0
	n = str(n)
	n = n[::-1]
	for i in range(len(n)):
		if n[i] is not '0':
			countothers += 1
		else:
			countzero += 1
		if countzero == k:
			break
	if countzero != k:
		print(len(n) - 1)
	else:
		print(countothers)


(n, k) = map(int, input().split())
x = str(n)
lx = len(x)
ans = 0
c0 = x.count('0')
if c0 < k:
	exit(print(lx - 1))
c0 = 0
for i in range(lx - 1, -1, -1):
	if x[i] != '0':
		ans += 1
	else:
		c0 += 1
	if c0 == k:
		break
print(ans)


def main():
	(n, k) = input().split()
	k = int(k)
	if k == 0:
		print(0)
		return
	zeros = ans = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			zeros += 1
		else:
			ans += 1
		if zeros == k:
			break
	else:
		ans = len(n) - 1
	print(ans)
main()


(n, k) = map(int, input().split())
n = list(map(int, list(str(n))))
if n.count(0) < k:
	print(len(n) - 1)
else:
	c = 0
	cd = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == 0:
			c += 1
		else:
			cd += 1
		if c == k:
			break
	print(cd)


(s, k) = [i for i in input().split()]
k = int(k)
s = s[::-1]
c = 0
cou = 0
flag = 0
for i in range(len(s)):
	if s[i] == '0':
		c += 1
		if c % k == 0:
			flag = 1
			break
	else:
		cou += 1
if flag == 1:
	print(cou)
else:
	print(len(s) - 1)


(n, k) = input().split()
k = int(k)
n = n[::-1]
cnt = 0
for i in range(len(n)):
	if n[i] == '0':
		cnt += 1
		if cnt == k:
			print(i - cnt + 1)
			exit()
print(len(n) - 1)


from sys import stdin, stdout
data = stdin.readline().split()
n = int(data[0])
k = int(data[1])
if n == 0 or n % 10 ** k == 0:
	stdout.write('0' + '\n')
	exit()
num = list(str(n))
delete = 0
zeroes = 0
for (index, value) in enumerate(num[::-1]):
	if value != '0':
		delete += 1
	else:
		zeroes += 1
	if zeroes >= k:
		stdout.write(str(delete) + '\n')
		exit(0)
stdout.write(str(len(num) - 1) + '\n')
exit(0)


(n, k) = input().split()
k = int(k)
l = len(n) - 1
c = 0
while l >= 0 and k:
	if n[l] == '0':
		k -= 1
	else:
		c += 1
	l -= 1
if k == 0:
	print(c)
else:
	print(len(n) - 1)


(n, k) = input().split()
(k, ans) = (int(k), 0)
for s in list(reversed(n)):
	if k <= 0:
		break
	if s == '0':
		k -= 1
	else:
		ans += 1
else:
	ans = len(n) - 1
print(ans)


import math
(n, k) = input().split()
(N, n) = (int(n), int(n))
k = int(k)
(count, ans) = (0, 0)
while count < k:
	if n % 10 == 0:
		count += 1
	else:
		ans += 1
	n //= 10
if N == 0:
	print(0)
elif n == 0:
	print(int(math.log10(N)))
else:
	print(ans)


import sys

def input():
	return sys.stdin.readline()
(n, k) = input().split()
deleted = 0
counted = 0
for s in n[::-1]:
	if s != '0':
		deleted += 1
	else:
		counted += 1
		if counted == int(k):
			print(deleted)
			sys.exit(0)
print(len(n) - 1)


(n, k) = input().split()
k = int(k)
count = 0
for c in n[::-1]:
	if not int(c):
		k -= 1
	else:
		count += 1
	if not k:
		break
else:
	print(len(n) - 1)
	exit(0)
print(count)


(n, k) = list(map(int, input().split()))
data = list(str(n))[::-1]
count = 0
err = 0
for item in data:
	if count == k:
		break
	if item == '0':
		count += 1
	else:
		err += 1
if count == k:
	print(err)
else:
	print(len(data) - 1)


import sys
import math
import bisect

def solve(s, m):
	n = len(s)
	cnt = 0
	for i in range(n - 1, -1, -1):
		if s[i] == '0':
			cnt += 1
		if cnt == m:
			return n - i - m
	return n - 1

def main():
	(s, m) = input().split()
	m = int(m)
	ans = solve(s, m)
	print(ans)
main()


linea = input().strip().split()
n = int(linea[0])
potencia = 10 ** int(linea[1])
count = 0
aux = list(linea[0])
if potencia > n:
	count = len(linea[0]) - 1
else:
	for i in range(len(linea[0]) - 1, -1, -1):
		n = int(''.join(aux))
		if n % potencia == 0:
			break
		elif aux[i] != '0':
			del aux[i]
			count += 1
	aux2 = set(aux)
	if '0' in aux2 and len(aux2) == 1:
		count += len(aux) - 1
print(count)


(a, b) = map(int, input().split())
z = list(str(a))
zeroc = z.count('0')
if zeroc < b:
	print(len(str(a)) - 1)
	exit()
c = 0
x = len(z) - 1
while int(''.join(z)) % 10 ** b > 0:
	if z[x] != '0':
		del z[x]
		c += 1
	x -= 1
print(c)


def solve():
	if n == '0':
		return 0
	cur = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == '0':
			cur += 1
		if cur == k:
			return len(n) - i - k
	return len(n) - 1
read = lambda : map(int, input().split())
(n, k) = read()
n = str(n)
print(solve())


(n, k) = input().split()
k = int(k)
if n.count('0') < k:
	exit(print(len(n) - 1))
n = list(n)
res = 0
while k:
	if '0' == n.pop():
		k -= 1
	else:
		res += 1
print(res)


def Pupils_redistribution():
	n = int(input())
	g1 = input().split()
	g1d = [0] * 5
	g2 = input().split()
	g2d = [0] * 5
	for i in g1:
		g1d[int(i) - 1] += 1
	for i in g2:
		g2d[int(i) - 1] += 1
	nd = [0] * 5
	for i in range(len(g1d)):
		a = g1d[i] - g2d[i]
		if a % 2 == 0:
			nd[i] = a / 2
		else:
			print('-1')
			break
	else:
		if sum(nd) == 0:
			sums = 0
			for i in nd:
				if i > 0:
					sums += i
			print(int(sums))
		else:
			print('-1')

def Weird_rounding():
	r = input().split()
	n = r[0]
	lenn = len(n)
	n2 = n
	k = int(r[1])
	ten = 10 ** k
	count = 0
	for i in range(lenn):
		if int(n2) % ten == 0:
			break
		if int(n2[lenn - i - 1]) != 0:
			count += 1
			n2 = n2[:lenn - i - 1] + n2[lenn - i:]
	if int(n2) == 0 and len(n2) > 1:
		print(count + len(n2) - 1)
	else:
		print(count)
Weird_rounding()


import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def nninp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
(n, k) = nninp()
l = stl(str(n))
cnt = l.count('0')
if cnt < k:
	if cnt > 0:
		print(len(l) - 1)
	else:
		print(len(l))
else:
	l.reverse()
	cnt = 0
	ans = 0
	for c in l:
		if c == '0':
			cnt += 1
		else:
			ans += 1
		if cnt == k:
			break
	p(ans)


(n, k) = map(int, input().split())
s = str(n)
z = 0
for i in s:
	if i == '0':
		z += 1
i = -1
c = 0
if k >= len(s) or z < k:
	c = len(s) - 1
else:
	while k > 0:
		if s[i] == '0':
			k -= 1
		else:
			c += 1
		i -= 1
print(c)


import collections
(s, k) = input().split()
arr = list(map(int, list(s[1:])))
n = 0

def cor(n, arr):
	for i in range(0, n):
		if arr[-(i + 1)] != 0:
			return False
	return True
if len(s) < int(k):
	print(len(s) - 1)
else:
	for i in range(len(arr) - 1, -1, -1):
		if arr[i] != 0:
			arr.pop(i)
			n += 1
		if len(arr) >= int(k) and cor(int(k), arr):
			break
		if len(arr) < int(k):
			n = len(s) - 1
			break
	print(n)


(n, k) = map(int, input().split())
n = str(n)
v = 0
answer = 0
t = False
for i in range(len(n) - 1, 0, -1):
	if n[i] == '0':
		v += 1
	else:
		answer += 1
	if v == k:
		t = True
		break
if t:
	print(answer)
else:
	print(len(n) - 1)