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