#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int lowbit(int x) { return x & -x; }
const double eps = 1e-8;
const int INF = 0x3F3F3F3F;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
char s[25];
int main() {
  int k;
  scanf("%s%d", s, &k);
  bool flag = false;
  int len = strlen(s), ans = 0, cnt = 0, i;
  for (i = len - 1; i >= 0; i--) {
    if (s[i] != '0') {
      ans++;
    } else {
      flag = true;
      while (s[i--] == '0') {
        cnt++;
        if (cnt % k == 0 && flag) {
          printf("%d\n", ans);
          return 0;
        }
      }
      i += 2;
    }
    if (cnt % k == 0 && flag) {
      printf("%d\n", ans);
      return 0;
    }
  }
  if (i < 0) {
    printf("%d\n", len - 1);
  }
}
