#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 11;
const long long M = 1 << 7;
const long long inf = 1e9 + 7;
const long long Mod = 1e9 + 7;
const double eps = 1e-6;
string s;
int k;
int main() {
  cin >> s >> k;
  int ans = 0;
  for (int i = s.size() - 1; i; --i) {
    if (s[i] == '0')
      k--;
    else
      ans++;
    if (k == 0) {
      cout << ans;
      exit(0);
    }
  }
  cout << s.size() - 1;
  return 0;
}
