#include <bits/stdc++.h>
double pi = 3.1415926535897932384626433832795028841971693993751;
using namespace std;
int a[1000000], b[1000000];
vector<int> s[100005];
int k = 0;
int main() {
  long long n;
  int k;
  scanf("%lld %d", &n, &k);
  long long k1 = n;
  int c1 = 0, c = 0, c2 = -1, res = -1;
  while (k1 != 0) {
    if (k1 % 10 == 0) c1++;
    if (c1 == 1 && c2 == -1) c2 = c;
    k1 = k1 / 10;
    c++;
    if (c1 == k && res == -1) res = c - c1;
  }
  if (n == 0) c++;
  if (res >= 0)
    printf("%d\n", res);
  else {
    printf("%d\n", c - 1);
  }
  return 0;
}
