#include <bits/stdc++.h>
using namespace std;
void afify() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long oo = (long long)1e13;
const double EPS = 1e-4;
int main() {
  afify();
  int k;
  string n;
  cin >> n >> k;
  int cnt = 0, res = 0, sum = 0;
  if (n.length() < k) {
    cout << n.length() - 1 << endl;
    return 0;
  }
  for (int i = n.length() - 1; i >= 0; i--) {
    if (n[i] == '0') {
      cnt++;
      sum++;
      if (cnt == k) {
        cout << res << endl;
        return 0;
      }
    } else {
      res++;
    }
  }
  cout << n.length() - 1 << endl;
  return 0;
}
