#include <bits/stdc++.h>
int solve(int64_t n, int64_t k) {
  if (n == 0) return 0;
  int l = 0;
  int res = 0;
  while (k > 0) {
    if (n < 10) return l;
    if (n % 10 == 0)
      --k;
    else
      ++res;
    ++l;
    n /= 10;
  }
  return res;
}
int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::cout << solve(n, k) << '\n';
}
