import Control.Applicative
import Data.List

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [n, k] = length $ unfoldr f n
  where
    f 0 = Nothing
    f x = let (q, r) = divMod x k in Just (r, q)
