#include <bits/stdc++.h>
using namespace std;
int* excount1;
int* excount2;
int* res;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int k;
  cin >> n >> k;
  int c = 0;
  if (n == 0) {
    cout << 0 << "\n";
    return 0;
  }
  int sol = 0;
  int counter = 0;
  while (c < k && n != 0) {
    if (n % 10 != 0)
      sol++;
    else
      c++;
    counter++;
    n = n / 10;
  }
  if (k == c) {
    cout << sol << "\n";
    return 0;
  } else {
    cout << counter - 1 << "\n";
    return 0;
  }
}
