#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, s1;
  cin >> s >> s1;
  int a = 0;
  int di = 0;
  while (s1 > 0 && s > 0) {
    int p = (s % 10);
    if (p != 0) {
      a++;
    } else {
      s1--;
      di++;
    }
    s /= 10;
  }
  if (di > 1 && s == 0) a += di - 1;
  cout << a << endl;
}
