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
    | k >= n = 1
    | otherwise = (loop 0 i) + loop' (n-1) i 
    where
        loop s curr
            | curr <= s = 0
            | otherwise = 1 + loop  s (curr-(k-1))
        loop' g curr
            | curr >= g = 0
            | otherwise = 1 + loop' g (curr+(k-1))
        
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