#include <bits/stdc++.h>
using namespace std;
string number;
int main() {
  int div;
  int c = 0;
  int c1 = 0;
  cin >> number >> div;
  for (int i = number.size() - 1; i >= 0; i--) {
    if (number[i] == '0') {
      c++;
    } else {
      c1++;
    }
    if (div == c) {
      printf("%d\n", c1);
      return 0;
    }
  }
  printf("%d\n", number.size() - 1);
  return 0;
}
