#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long i, j, k, n, sl, count = 0, noofzeros = 0;
  cin >> s;
  cin >> k;
  sl = s.length();
  long long boss = k;
  if (boss >= sl) {
    cout << sl - 1;
    return 0;
  }
  for (i = sl - 1; i >= 0; i--) {
    if (s[i] == '0') {
      noofzeros++;
    }
    if (noofzeros == k) {
      if (noofzeros == k) break;
    }
    if (s[i] != '0') {
      count++;
    }
  }
  if (noofzeros < k) {
    cout << sl - 1;
    return 0;
  }
  cout << count << endl;
  return 0;
}
