module Main where

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr, break)

readInts :: B.ByteString -> [Int]
readInts bs = unfoldr (B.readInt . B.dropWhile (== ' ')) bs

main :: IO ()
main = do
    [n, k] <- readInts <$> B.getLine
    as <- readInts <$> B.getLine
    let (ls, rs) = (\(a, b) -> (length a, length $ drop 1 b)) $ break (== 1) as
    let l = (ls + k - 2) `div` (k - 1)
    let r = (rs + k - 2) `div` (k - 1)
    print $ l + r