#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i = 0, a = 0, b, cou = 0, cou1 = 0, ck = 1, cc = 0;
  cin >> n >> k;
  if (n < pow(10, k)) {
    while (n) {
      n = n / 10;
      cou++;
    }
    if (cou == 0)
      cout << 0 << endl;
    else
      cout << cou - 1 << endl;
  } else {
    while (n) {
      if (n % 10 == 0) {
        cou++;
        if (k == cou) {
          ck = 0;
        }
      } else {
        if (ck) cou1++;
      }
      n = n / 10;
      cc++;
    }
    if (cou < k)
      cout << cc - 1 << endl;
    else
      cout << cou1 << endl;
  }
  return 0;
}
