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