#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  long long m = n;
  long long c = 0;
  long long ans = 0;
  while (m != 0) {
    long long d = m % 10;
    if (d == 0) {
      c++;
    } else {
      ans++;
    }
    if (c == k) {
      break;
    }
    m = m / 10;
  }
  if (c == k) {
    cout << ans << endl;
  } else {
    m = n;
    long long ra = -1;
    if (m == 0) {
      cout << 0 << endl;
      return 0;
    }
    while (m != 0) {
      ra++;
      m = m / 10;
    }
    cout << ra << endl;
  }
  return 0;
}
