#include <bits/stdc++.h>
using namespace std;
int dig[15];
int main() {
  int n, k, m;
  scanf("%d%d", &n, &k);
  int len = 0;
  m = n;
  while (n) {
    dig[++len] = n % 10;
    n = n / 10;
  }
  if (m == 0)
    printf("0\n");
  else {
    int cnt = 0, num = 0;
    int ok = 0;
    for (int i = 1; i <= len; i++) {
      if (dig[i] == 0)
        num++;
      else
        cnt++;
      if (num == k) {
        ok = 1;
        break;
      }
    }
    if (ok == 1)
      printf("%d\n", cnt);
    else {
      printf("%d\n", len - 1);
    }
  }
  return 0;
}
