#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  ;
  string s;
  int n, ans = 0;
  cin >> s >> n;
  int nn;
  for (int i = s.size() - 1; i > 0; i--) {
    if (n == nn) break;
    if (s[i] != '0')
      ans++;
    else
      nn++;
  }
  if (s.size() - ans > n)
    cout << ans;
  else
    cout << s.size() - 1;
  return 0;
}
