#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 5e5 + 5;
const int INF = 0x7fffffff;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
int main() {
  int n, m;
  cin >> n >> m;
  int t = n, num = 0;
  while (t > 0) {
    if (t % 10 == 0) num++;
    t /= 10;
  }
  if (num >= m) {
    int pos = 0;
    while (m > 0) {
      if (n % 10 == 0)
        m--;
      else
        pos++;
      n /= 10;
    }
    cout << pos << endl;
  } else {
    if (n == 0) {
      puts("0");
      return 0;
    }
    int pos = 0;
    while (n > 0) {
      pos++;
      n /= 10;
    }
    cout << pos - 1 << endl;
  }
  return 0;
}
