#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x;
  char a[15];
  int k, i = 0, count = 0, l = -1;
  cin >> n;
  cin >> k;
  x = n;
  while (n != 0) {
    l++;
    a[l] = (n % 10) + '0';
    n = n / 10;
  }
  while (i <= l && count < k) {
    if (a[i] == '0') count++;
    i++;
  }
  if (x == 0)
    cout << 0 << endl;
  else if (count == k)
    cout << i - count << endl;
  else if (count < k) {
    cout << l << endl;
  }
}
