{-# OPTIONS_GHC -O #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as B

main=do
    [n,k]<-map read.words<$>getLine :: IO [Int]
    as <- unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    --
    print $ if n<=k
        then 1
        else let (c,bs) = lchk k as in (+) c $ fst $ lchk k (reverse bs)

lchk k ar =
    let
        n = ((f1 ar) + k-2) `div` (k-1)
    in
        (n, (1:(drop (n*(k-1)+1) ar)))

f1 as = case findIndex (==1) as of
            Just i -> i
            Nothing -> undefined
