var l = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n');
var K = Number(l[0].split(' ')[1]), S = l[1].split('');
var n = S[0], nc = 1, l = [];
for (var i = 1; i < S.length; i++) {
  if (n === S[i]) nc++
  else {
    l.push({s: n, l: nc});
    nc = 1;
    n = S[i];
  }
}
l.push({s: n, l: nc});
var r = [];
  for (var i = 0; i < l.length; i++) {
    if (l[i].s === '0') {
      var c1 = 0, c1k = l[i].l, ck = 0;
      for (var k = i + 1; k < l.length; k++) {
        if (K === 1) {
          break;
        } else if (l[k].s === '1') {
          c1++;
        } else if (c1 === K - 1) {
          c1k += l[k].l;
          ck = k;
          break;
        } else {
          c1k += l[k].l;
        }
      }
      r.push({i, k, c1k});
    }
  }
if (r.length !== 0) {
  r = r.reduce((a,b) => a.c1k > b.c1k ? a : b);
  var sum = 0;
  for (var i = r.i; i <= r.k; i++) sum += l[i].l;
  if (r.i > 0) sum += l[r.i - 1].l;
  if (r.k + 1 < l.length) sum += l[r.k + 1].l;
  console.log(sum);
} else {
  console.log(l.filter(a => a.s === '1').reduce((a, b)=> a>b?a:b, 0).l);
}