#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long k, n;
  n = atoi(s.c_str());
  long long cnt = 0;
  long long cntzero = 0;
  long long cntnumber = 0;
  cin >> k;
  long long x = pow(10, k);
  if (n % x == 0) {
    cout << 0 << endl;
    return 0;
  } else if (n < x) {
    cout << s.size() - 1;
    return 0;
  } else {
    for (int i = s.size() - 1; i >= 0; i--) {
      if (s[i] == '0')
        cntzero++;
      else
        cnt++;
      if (cntzero == k) {
        cout << cnt;
        return 0;
      }
    }
  }
  cout << s.size() - 1;
  return 0;
}
