#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  int k;
  cin >> n >> k;
  if (n == 0)
    cout << 0 << endl;
  else {
    int ans = 0, l = 0;
    while (k > 0 and n != 0) {
      if (n % 10 != 0)
        ans = ans + 1;
      else
        k = k - 1;
      l = l + 1;
      n = n / 10;
    }
    if (n != 0)
      cout << ans << endl;
    else
      cout << l - 1 << endl;
  }
}
