#include <bits/stdc++.h>
using namespace std;
map<int, int> MAP;
int q[1000];
int main() {
  long long n, k;
  scanf("%I64d%I64d", &n, &k);
  long long n1 = n;
  int k1 = 0;
  int sum = 0;
  while (n) {
    q[k1++] = n % 10;
    sum++;
    n /= 10;
  }
  if (n1 == 0) {
    printf("0\n");
    return 0;
  }
  if (sum - 1 < k) {
    printf("%d\n", sum - 1);
    return 0;
  }
  int sum1 = 0;
  int shan = 0;
  for (int i = 0; i < k1; i++) {
    if (q[i] == 0)
      sum1++;
    else
      shan++;
    if (sum1 >= k) break;
  }
  if (sum1 >= k)
    printf("%d\n", shan);
  else
    printf("%d\n", sum - 1);
}
