{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	idx <- fromJust . elemIndex 1 <$> readInts
	print $ minimum $ do
		l <- [ 0 .. k - 1 ]
		let
			r = k - 1 - l

			ll = max 0 $ idx - l
			rr = max 0 $ ( n - 1 - idx ) - r

			f a = ( a + ( k - 1 ) - 1 ) `div` ( k - 1 )
		return $ 1 + f ll + f rr