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