#include <bits/stdc++.h>
using namespace std;
const double eps = 0.0000001;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int c1[6], c2[6];
int main() {
  char num[100];
  int k;
  scanf("%s%d", num, &k);
  int len = strlen(num);
  int ans = 0, dd = 0;
  for (int i = len - 1; i >= 0; i--) {
    if (num[i] == '0')
      dd++;
    else
      ans++;
    if (dd == k) break;
  }
  if (dd < k) ans = len - 1;
  if (num[0] == '0') ans = 0;
  cout << ans << endl;
}
