#include <bits/stdc++.h>
using namespace std;
int n, k, re, ti;
int main() {
  scanf("%d%d", &n, &k);
  while (k) {
    int now = n % 10;
    if (now == 0) {
      k--;
    } else {
      re++;
    }
    n = n / 10;
    ti++;
    if (n == 0) break;
  }
  if (n == 0 && k)
    cout << ti - 1;
  else
    cout << re;
  return 0;
}
