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