#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  int k;
  cin >> n >> k;
  long long num = 1;
  for (int i = 1; i <= k; i++) num *= 10;
  if (atoll(n.c_str()) % num == 0) {
    cout << "0";
    return 0;
  }
  string newe;
  vector<int> Places;
  int counter = 0;
  int bad = 0;
  for (int i = n.length() - 1; i >= 0; i--) {
    if (counter == k) {
      newe += n[i];
      continue;
    }
    bool add = true;
    if (n[i] == '0')
      counter++;
    else
      bad++, Places.push_back(bad), add = false;
    if (add) newe += n[i];
  }
  reverse(newe.begin(), newe.end());
  bool onlyZero = true;
  for (int i = 0; i < newe.length(); i++) {
    if (newe[i] != '0') onlyZero = false;
  }
  if (atoll(newe.c_str()) % num == 0) {
    if (onlyZero) {
      cout << n.length() - 1;
      return 0;
    }
    cout << bad;
    return 0;
  }
  cout << n.length() - 1;
  return 0;
}
