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