#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0, zeroes = 0;
  cin >> n >> k;
  while (n != 0) {
    if (n % 10 != 0)
      ans++;
    else
      zeroes++;
    if (zeroes == k) break;
    n = n / 10;
  }
  if (zeroes < k) {
    if (zeroes != 0) ans = ans + zeroes - 1;
  }
  printf("%d\n", ans);
}
