#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, k, b, ss, c, a[100];
  cin >> n >> k;
  m = pow(10, k);
  if (n == 0)
    b = 0;
  else if (n / m == 0) {
    b = log10(n);
  } else {
    c = log10(n) + 1;
    j = c;
    ss = c - 1;
    while (c--) {
      a[c] = n % 10;
      n = n / 10;
    }
    int cnt = 0, cn = 0, tsa = 0;
    for (i = 0; j--; i++) {
      if (cnt == k) {
        tsa = 1;
        break;
      }
      if (a[j] == 0) {
        cnt++;
      } else
        cn++;
    }
    if (tsa == 1)
      b = cn;
    else
      b = ss;
  }
  cout << b << endl;
  return 0;
}
