#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a;
  cin >> a;
  int k;
  cin >> k;
  string in = to_string(a);
  if (in == "0") {
    cout << 0 << endl;
    return 0;
  }
  int i = in.size() - 1;
  int cnt = 0;
  string t = "";
  while (i >= 1) {
    if (in[i] == '0') {
      cnt++;
    }
    if (cnt == k) {
      t = in.substr(i, in.size() - i);
      break;
    }
    i--;
  }
  if (t.size() == 0) {
    cout << in.size() - 1 << endl;
  } else {
    int ans = 0;
    for (int i = 0; i < t.size(); i++) {
      if (t[i] != '0') ans++;
    }
    cout << ans << endl;
    return 0;
  }
}
