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