#include <bits/stdc++.h>
using namespace std;
int i, n, k, p;
int main() {
  string a;
  cin >> a >> n;
  for (i = a.size() - 1; i > 0; i--) {
    if (a[i] != '0') {
      p++;
    } else
      k++;
    if (k == n) {
      cout << p;
      return 0;
    }
  }
  cout << a.size() - 1;
}
