#include <bits/stdc++.h>
using namespace std;
int main() {
  string num;
  int c = 0, c0 = 0, k;
  cin >> num >> k;
  for (int i = num.length() - 1; i >= 0; i--) {
    if (c0 == k) break;
    if (num[i] != '0')
      c++;
    else
      c0++;
  }
  if (c0 < k) c = num.length() - 1;
  cout << c << endl;
  return 0;
}
