#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  int k;
  cin >> s >> k;
  if (s == "0")
    cout << 0 << endl;
  else {
    int c1 = 0, ans = 0;
    for (int i = (int)(s.size()) - 1; i >= 0; i--) {
      if (c1 >= k) break;
      if (s[i] == '0') {
        c1++;
      } else {
        ans++;
      }
    }
    if (c1 < k) {
      cout << (int)(s.size()) - 1 << endl;
    } else
      cout << ans << endl;
  }
  return 0;
}
