#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  int n, k, answer, zeros;
  char s[11];
  fscanf(stdin, "%d %d", &n, &k);
  sprintf(s, "%d", n);
  if (n == 0) {
    printf("0\n");
    return 0;
  }
  if (strlen(s) - 1 < k) {
    printf("%d\n", strlen(s) - 1);
    return 0;
  }
  for (int i = strlen(s) - 1; i > 0; i--) {
    if (s[i] != '0')
      answer++;
    else
      zeros++;
    if (zeros == k)
      break;
  }
  if (zeros != k)
    answer = strlen(s) - 1;
  printf("%d\n", answer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1050 <fscanf@plt>
lea    -0x1f(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe89(%rip),%rsi
call   1060 <sprintf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11a3 <main+0x63>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1279 <main+0x139>
lea    -0x1f(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cmp    -0xc(%rbp),%eax
jge    11e0 <main+0xa0>
lea    -0x1f(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
sub    $0x1,%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1279 <main+0x139>
lea    -0x1f(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1246 <main+0x106>
movslq -0x24(%rbp),%rax
movsbl -0x1f(%rbp,%rax,1),%eax
cmp    $0x30,%eax
je     1219 <main+0xd9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1222 <main+0xe2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1233 <main+0xf3>
jmp    1246 <main+0x106>
jmp    1238 <main+0xf8>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11ef <main+0xaf>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1261 <main+0x121>
lea    -0x1f(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1060 <fscanf@plt>
mov    0xc(%rsp),%edx
lea    0xe81(%rip),%rsi
lea    0x15(%rsp),%rdi
call   1070 <sprintf@plt>
cmpl   $0x0,0xc(%rsp)
je     11c8 <main+0x78>
lea    0x15(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %ebx,%ebp
jle    11d6 <main+0x86>
lea    0x15(%rsp),%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%esi
lea    0xe40(%rip),%rdi
jmp    11e2 <main+0x92>
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
jmp    11e9 <main+0x99>
add    $0xffffffff,%eax
lea    0xe26(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"0\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [11 x i8]
%7 = alloca i32
store i32 0, i32* %1
%8 = load i32, i32* @stdin
%9 = call i32 @fscanf(i32 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %68
17: ; preds = %0
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = load i32, i32* %3
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = sub nsw i32 %25, 1
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
store i32 0, i32* %1
br label %68
28: ; preds = %17
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 1
store i32 %31, i32* %7
br label %32
32: ; preds = %54, %28
%33 = load i32, i32* %7
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %57
35: ; preds = %32
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 48
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %48
45: ; preds = %35
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %48
48: ; preds = %45, %42
%49 = load i32, i32* %5
%50 = load i32, i32* %3
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %53
52: ; preds = %48
br label %57
53: ; preds = %48
br label %54
54: ; preds = %53
%55 = load i32, i32* %7
%56 = add nsw i32 %55, -1
store i32 %56, i32* %7
br label %32
57: ; preds = %52, %32
%58 = load i32, i32* %5
%59 = load i32, i32* %3
%60 = icmp ne i32 %58, %59
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%63 = call i32 @strlen(i8* %62)
%64 = sub nsw i32 %63, 1
store i32 %64, i32* %4
br label %65
65: ; preds = %61, %57
%66 = load i32, i32* %4
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %66)
store i32 0, i32* %1
br label %68
68: ; preds = %65, %23, %15
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [11 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fscanf(i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%9 = load i32, i32* %1
%10 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %27
15: ; preds = %0
%16 = call i32 @strlen(i8* %6)
%17 = load i32, i32* %2
%18 = icmp sgt i32 %16, %17
%19 = call i32 @strlen(i8* %6)
br i1 %18, label %23, label %20
20: ; preds = %15
%21 = add nsw i32 %19, -1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %27
23: ; preds = %15
%24 = call i32 @strlen(i8* %6)
%25 = add nsw i32 %24, -1
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23, %20, %13
ret i32 0
}