module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.Vector as V
import Data.Maybe 
import qualified Data.Text as T
import qualified Data.Text.IO as TIO


makeGroup :: T.Text -> [Int]
makeGroup people = let 
    initialAccum = ([], 1, T.head people)
    (groupList, lastGroup, _) = T.foldl' inner initialAccum (T.tail people) 
    in 
        reverse $ lastGroup : groupList
        where
    inner :: ([Int], Int, Char) -> Char -> ([Int], Int, Char)
    inner (groupList, currentNumber, currentStat) person = 
        if person == currentStat then
            (groupList, currentNumber + 1, currentStat)
        else
            (currentNumber : groupList, 1, person)

solve :: T.Text -> Int -> Int
solve people orderTime = 
        fst $ foldl' inner (firstGroup, firstGroup) indexes
    where
    group =  if T.head people == '0'
        then 
            0 : makeGroup people
        else 
            makeGroup people
    groupLength = length group
    groupArr = V.fromList group
    getGroup i = fromMaybe 0 $ groupArr V.!? i
    joinableGroupNum = orderTime * 2 + 1
    firstGroup = sum $ V.take joinableGroupNum groupArr 
    indexes = [x| x<- [2..groupLength], even x]
    inner (biggest, current) index = let
        minus = getGroup (index - 1) + getGroup (index - 2)
        plus = getGroup (index + joinableGroupNum - 1) + getGroup (index + joinableGroupNum - 2)
        next = current + plus - minus
        in
            (max biggest next, next)

readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)


main = do
    (_, k) <- readTuple
    people <- TIO.getLine
    print $ solve people k


