#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  string n;
  cin >> n >> k;
  int num = 0;
  for (int i = 0; i < n.length(); i++) {
    if (n[i] == '0') num++;
  }
  if (num < k)
    cout << n.length() - 1;
  else if (num == k) {
    int pot = 0, ans = 0;
    for (int i = n.length() - 1; i >= 0; i--) {
      if (n[i] == '0') pot++;
      if (pot == k) break;
      if (n[i] != '0') ans++;
    }
    cout << ans;
  } else if (num > k) {
    int pot = 0, ans = 0;
    for (int i = n.length() - 1; i >= 0; i--) {
      if (n[i] == '0') pot++;
      if (pot == k) break;
      if (n[i] != '0') ans++;
    }
    cout << ans;
  }
}
