#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[15];
  long long int k, i, count = 0, l, temp = 0;
  cin >> a >> k;
  l = strlen(a);
  for (i = l - 1; i >= 0; i--) {
    if (a[i] != '0')
      temp++;
    else
      count++;
    if (count == k) {
      cout << temp << endl;
      return 0;
    }
  }
  if (count < k) {
    cout << l - 1 << endl;
    return 0;
  }
}
