#include <bits/stdc++.h>
using namespace std;
int n;
long long x;
int main() {
  cin >> x >> n;
  int ans = 0, t = 0;
  if (x == 0) return cout << 0, 0;
  while (x) {
    if (x % 10 != 0)
      ans++;
    else
      t++;
    if (t == n) break;
    x /= 10;
  }
  if (x == 0 && t != n)
    cout << ans + t - 1;
  else
    cout << ans;
}
