#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  int k, nbzeros = 0, nbtodel = 0;
  cin >> n >> k;
  if (count(n.begin(), n.end(), '0') < k)
    cout << n.size() - 1 << endl;
  else {
    for (int i = n.size() - 1; i >= 0 && nbzeros < k; i--) {
      if (n[i] == '0')
        nbzeros++;
      else
        nbtodel++;
    }
    cout << nbtodel << endl;
  }
  return 0;
}
