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