#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int n, k, s;
  cin >> n >> k;
  s = n;
  int req = 0;
  int got = 0;
  while (n > 0) {
    got += ((n % 10) == 0);
    if (got == k) break;
    req += ((n % 10) != 0);
    n /= 10;
  }
  if (n == 0 && got != k) {
    if (s == 0)
      req = 0;
    else
      req = log10(s);
  }
  cout << req;
  return 0;
}
