import Data.List
-- n を k 進数
solve t n = loop t 0 
    where
        loop :: Int -> Int -> [Int]
        loop t i
            | t == 0 = []
            | otherwise =
                let
                    (t', k) = quotRem t n
                in
                    k : loop t' (i+1)

main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    print $ length $ solve n k