#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k, count = 0, rem = 0;
  cin >> s >> k;
  int l = s.length() - 1;
  while (l != -1) {
    if (s[l] == '0') {
      count++;
      if (count == k) {
        cout << rem;
        return 0;
      }
    } else {
      rem++;
    }
    l--;
  }
  if (s == "0") {
    cout << "0";
    return 0;
  }
  cout << s.length() - 1;
}
