#include <bits/stdc++.h>
using namespace std;
const int m = 15;
int main() {
  string s;
  int i, j, k, counter0 = 0, counter1 = 0;
  cin >> s;
  int len = s.size();
  cin >> k;
  for (i = len - 1; i >= 0; i--) {
    if (s[i] == 48 && counter0 < k) {
      counter0++;
    }
    if (counter0 >= k) {
      break;
    }
  }
  if (counter0 >= k) {
    for (j = i + 1; j < len; j++) {
      if (s[j] != 48) {
        counter1++;
      }
    }
    cout << counter1 << endl;
  } else {
    cout << len - 1 << endl;
  }
  return 0;
}
