#include <bits/stdc++.h>
using namespace std;
const long long MAXX = 1e5 + 100;
const long long INF = 1e9 + 7;
long long n, k, p, ans, r;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long x = n;
  while (x > 0) {
    if (x % 10 == 0)
      p++;
    else if (p < k) {
      ans++;
    }
    x /= 10;
    r++;
  }
  if (p >= k) {
    cout << ans << endl;
    return 0;
  }
  if (p > 0)
    cout << r - 1 << endl;
  else
    cout << r << endl;
}
