#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int k, n, c = 0, f = 0;
  string str;
  cin >> str >> k;
  n = str.size();
  for (int i = n - 1; i >= 0 && k != 0; i--) {
    if (str[i] == '0') {
      k--;
      f = 1;
      continue;
    }
    c++;
  }
  if (k) c = n - f;
  cout << c << endl;
  return 0;
}
