#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  short k;
  cin >> n;
  cin >> k;
  long clone = n;
  int count = 0;
  do {
    clone /= 10;
    count++;
  } while (clone > 0);
  if (k >= count) {
    cout << count - 1;
    return 0;
  }
  short out = 0;
  clone = n;
  int need = 0;
  while (need < k && clone / 10 != 0) {
    if (clone % 10 != 0) {
      out++;
    } else {
      need++;
    }
    clone /= 10;
  }
  if (need < k) {
    cout << count - 1;
  } else {
    cout << out;
  }
}
