#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vii = vector<pii>;
using vs = vector<string>;
const double PI = acos(-1.0);
const double EPS = 1e-14;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFLL = 4e18;
const int MAX = 9;
string n;
int k;
int ans;
void read() { cin >> n >> k; }
void solve() {
  for (int i = (int)(int)n.size() - 1; i >= (int)0; i--) {
    if (n[i] == '0') {
      k--;
    } else {
      ans++;
    }
    if (k == 0) {
      cout << ans << "\n";
      return;
    }
  }
  cout << (int)n.size() - 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC = 1;
  while (TC--) {
    read();
    solve();
  }
}
