#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  int sum = 0, c = 0;
  bool f = false;
  while (sum <= k && n > 0) {
    int h = n % 10;
    n /= 10;
    if (h == 0)
      sum++;
    else
      c++;
    if (sum == k) {
      f = true;
      break;
    }
  }
  if (f == true)
    cout << c << endl;
  else {
    if (sum > 0)
      cout << c + sum - 1 << endl;
    else
      cout << sum + c << endl;
  }
}
