#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  int k, erase = 0, zero = 0;
  string s;
  cin >> n >> k;
  s = to_string(n);
  int j = s.length();
  for (int i = j - 1; i >= 0 && (zero != k); i--) {
    if (s[i] != '0')
      erase++;
    else
      zero++;
  }
  if (zero < k)
    cout << j - 1 << endl;
  else
    cout << erase << endl;
  return 0;
}
