<?php

//----------------------------------------------------------------------------------
// Input
//----------------------------------------------------------------------------------
$sc = new Scanner();
$n = $sc->nextInt();
$k = $sc->nextInt();
$s = $sc->next();

//$h = array();
//for ($i = 0; $i < $n; $i++) {
//  $h[] = $sc->next();
//}

//  $t = array();
//  $d = array();
//  for ($i = 0; $i < $n; $i++) {
//    $t[] = $sc->next();
//    $d[] = $sc->next();
//  }



//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

$t0 = array();
$t1 = array();
$curr = 1;
if ($s[0] == 0) { $t1[] = 0; $t0[] = 0; $curr = 0; }
else { $t1[] = 0; }
foreach (range(0, strlen($s)-1) as $i) {
  if ($s[$i] == $curr && $curr == 0) { $t0[count($t0)-1]++; }
  if ($s[$i] == $curr && $curr == 1) { $t1[count($t1)-1]++; }
  if ($s[$i] <> $curr && $curr == 0) { $t1[] = 1; $curr = 1; }
  if ($s[$i] <> $curr && $curr == 1) { $t0[] = 1; $curr = 0; }
}

$c = 0;
foreach (range(0, count($t0)-$k) as $i) {
  if ($i == 0) {
    foreach (range($i, $i+$k-1) as $j) {
      $c += $t1[$j]+$t0[$j];
    }
    $c += $t1[$i+$k];
  } else {
    $c -= $t1[$i-1]+$t0[$i-1];
    $c += $t1[$i+$k]+$t0[$i+$k-1];
  }
  $ans = max($c, $ans);
}

$ans2 = 0;
foreach (range(0, strlen($s)-1) as $i) {
  $ans2 += (int) $s[$i];
}
if ($ans2 == strlen($s)) { $ans = $ans2; }
if ($k > count($t0)) { $ans = strlen($s); }


//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
$is_large_int_ans = 0;
$is_multi_ans = 0;

if ($is_multi_ans) {
  for ($i = 0; $i < count($ans); $i++) {
    out::println($ans);
  }
} else {
  out::println($ans);
}



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;

  private $fp = NULL;

  function __construct() {
    $folder = explode("\\", getcwd());
    if (end($folder) == 'AtCoder') {
      error_reporting(E_ERROR | E_WARNING | E_PARSE);
      $this->fp = fopen('./Input.dat' , 'r');
    } else {
      error_reporting(0);
    }
  }

  public function next() {
    if($this->pointer >= $this->count) {
      $folder = explode("\\", getcwd());
      if (end($folder) == 'AtCoder') {
        $str = trim(fgets($this->fp));
      } else {
        $str = trim(fgets(STDIN));
      }
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    global $is_large_int_ans;
    if ($is_large_int_ans) {
      echo sprintf("%d", $str) . PHP_EOL;
    } else {
      echo $str . PHP_EOL;
    }
  }
}

?>


Measured memory_bytes: 14840