#include <bits/stdc++.h>
using namespace std;
int prez[20];
int zeros[20];
int nzeros[20];
vector<int> z;
int ans;
int main() {
  string x;
  cin >> x;
  int k;
  cin >> k;
  if (x == "0") {
    cout << 0 << "\n";
    return 0;
  }
  ans = x.length() - 1;
  zeros[0] = 0;
  nzeros[0] = 1;
  for (int i = 1; i < x.length(); i++) {
    if (int(x[i] - '0') == 0) {
      zeros[i] = zeros[i - 1] + 1;
      nzeros[i] = nzeros[i - 1];
      z.push_back(i);
    } else {
      zeros[i] = zeros[i - 1];
      nzeros[i] = nzeros[i - 1] + 1;
    }
  }
  for (int i = k - 1; i < z.size(); i++) {
    ans = min(ans, nzeros[x.length() - 1] - nzeros[z[i - k + 1]]);
  }
  cout << ans << "\n";
}
