#include <bits/stdc++.h>
using namespace std;
void check(long long int N, long long int K) {
  if (N == 0) {
    cout << 0 << endl;
    return;
  }
  vector<long long int> arr;
  while (N) {
    arr.push_back(N % 10);
    N = N / 10;
  }
  long long int s_ze = 0, ans = 0;
  for (long long int i = 0; i < arr.size(); i++) {
    if (arr[i] == 0) {
      K--;
      s_ze++;
      if (K == 0) break;
    } else {
      ans++;
    }
  }
  if (K != 0) {
    ans += s_ze - 1;
    cout << ans << endl;
  } else
    cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1;
  for (long long int i = 0; i < T; i++) {
    long long int N, K;
    cin >> N >> K;
    check(N, K);
  }
  return 0;
}
