#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string n;
  int k;
  cin >> n >> k;
  int ans = 0;
  int p = 0;
  for (auto it = n.rbegin(); p < k && it != n.rend();) {
    if (*it != '0') {
      ++ans;
      n.erase((++it).base());
    } else {
      ++it;
      ++p;
    }
  }
  for (auto it = n.begin(); it != n.end() && it + 1 != n.end(); ++it) {
    if (*it == '0') {
      ++ans;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
