#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, cnt = 0;
  string s;
  cin >> s >> n;
  for (i = s.size() - 1; i >= 0 && n; i--) {
    if (s[i] == '0')
      n--;
    else
      cnt++;
  }
  if (i < 0) {
    cout << s.size() - 1 << endl;
  } else
    cout << cnt << endl;
}
