#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(int argc, char **argv) {
  srand(time(0));
  ll x;
  int k;
  scanf("%lld%d", &x, &k);
  if (x == 0) {
    printf("0\n");
  } else {
    int dz = 0, dnz = 0;
    while (x != 0) {
      if (x % 10 != 0) {
        ++dnz;
      } else {
        ++dz;
      }
      if (dz == k) {
        printf("%d\n", dnz);
        exit(0);
      }
      x /= 10;
    }
    printf("%d\n", dz + dnz - 1);
  }
  return 0;
}
