module Main where

import Debug.Trace

main :: IO ()
main = (input 0) >>= output

input :: Int -> IO (Int, String)
input 0 = getLine >>= return . read . (!! 1) . words >>= input
input i = getLine >>= (return . ((,) i))

output :: (Int, String) -> IO ()
output (k, ks) = print $ search '1' ks k [(0,0)]
    where
        search :: Char -> String -> Int -> [(Int,Int)] -> Int
        search _ [] _ ks = maximum $ map snd ks
        search '1' ('0':xs) k ks = search '0' xs k $ incr k ks [] True
        search '0' ('1':xs) k ks = search '1' xs k $ incr k ((0,0):ks) [] False
        search _ (x:xs) k ks = search x xs k $ incr k ks [] False
        incr k [] ks _ = ks
        --incr k [] ks _ = traceShow ks ks
        incr k ((i,x):xs) ks inc
            | inc && i <= k = incr k xs ((i+1,x+1):ks) inc
            | inc = incr k xs ((i,x):ks) inc
            | i <= k = incr k xs ((i,x+1):ks) inc
            | otherwise = incr k xs ((i,x):ks) inc
