#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string n;
  long left, right = 9999999999, zero = 0, temp = 0;
  int k;
  cin >> n >> k;
  left = n.size() - 1;
  for (int i = left; i > 0; i--) {
    if (n[i] == '0') {
      zero++;
      if (k == zero) {
        right = temp;
        break;
      }
    } else
      temp++;
  }
  cout << min(left, right);
  return 0;
}
