#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  int cur = 0;
  int i;
  bool o = false;
  for (i = s.length() - 1; i >= 0; i--) {
    if (s[i] == '0') {
      cur++;
    }
    if (cur == k) {
      o = true;
      break;
    }
  }
  if (!o) {
    cout << s.length() - 1 << endl;
    return 0;
  }
  int r = 0;
  for (int j = s.length() - 1; j >= i; j--) {
    if (s[j] != '0') {
      r++;
    }
  }
  cout << r << endl;
  return 0;
}
