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