#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  int k, rez, cifre, secv;
  scanf("%I64d %d", &n, &k);
  rez = 0;
  cifre = 0;
  if (n == 0) {
    cifre = 1;
  }
  while (n % 10 != 0) {
    ++rez;
    n = n / 10;
    ++cifre;
  }
  secv = 0;
  while (n > 0) {
    while (n % 10 == 0) {
      ++secv;
      ++cifre;
      n = n / 10;
    }
    if (secv >= k) {
      printf("%d\n", rez);
      return 0;
    }
    while (n % 10 != 0) {
      ++rez;
      n = n / 10;
      ++cifre;
    }
  }
  rez = cifre - 1;
  printf("%d\n", rez);
  return 0;
}
