import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

solve :: Int -> Int -> Int -> Int 
solve n k i = (f left) + f right
    where
        f a = ceiling $ (fromIntegral a) / 2
        left = length $ [0..i-(k-1)] 
        right = length $ [i+(k-1)..n] 

main = do
    [n,k] <- map read . words <$> getLine
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    let Just i = VU.elemIndex 1 xs
    print $ solve n k i