#include <bits/stdc++.h>
using namespace std;
int pow(int n, int k) {
  if (k == 0) return 1;
  int sum = n;
  for (int i = 2; i <= k; i++) sum *= n;
  return sum;
}
int main() {
  int a[15] = {0};
  int n, k;
  cin >> n >> k;
  if (n < pow(10, k)) {
    int ans = 0;
    int sign = 0;
    while (n / 10) {
      ans++;
      if (n % 10 == 0) sign = 1;
      n /= 10;
    }
    if (n == 0) sign = 1;
    ans++;
    if (sign == 1) ans--;
    cout << ans << endl;
  } else {
    int a[100], b[100];
    int count = 1;
    int num = 0;
    while (n / 10) {
      if (n % 10 == 0) {
        b[++num] = count;
      }
      a[count++] = n % 10;
      n /= 10;
    }
    if (n % 10 == 0) {
      b[++num] = count;
    }
    a[count] = n;
    int ans = 0;
    if (num < k) {
      ans = count;
      if (num != 0) ans--;
    } else {
      int cur = b[k];
      for (int i = cur; i >= 1; i--) {
        if (a[i] != 0) ans++;
      }
    }
    cout << ans << endl;
  }
}
