#include <bits/stdc++.h>
using namespace std;
string n;
int k, w, p, L;
int main() {
  cin >> n >> k;
  L = n.length() - 1;
  p = L;
  for (p = L; p > 0 && L - p - w < k; p--)
    if (n[p] != '0') w++;
  if (L - p - w < k) w = L;
  cout << w << endl;
}
