import qualified Data.ByteString.Char8 as B
import Data.Ratio

solve :: Int -> Int -> Int 
solve n k = ceiling $ (n-1) % (k-1)
        
main = do
    [n,k] <- map read . words <$> getLine
    _ <- B.getLine
    print $ solve n k