intToKString :: Int -> Int -> String
intToKString x n
    | n == 0 = []
    | n == 1 = replicate x '1'
    | n <= 16 = getKString x n
    | otherwise = []
    where
        getKString :: Int -> Int -> String
        getKString x n
            | x == 0 = []
            | otherwise = (getKString (x `div` n) n) ++ (numbers !! (x `mod` n))
            where numbers = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
main = do
    [n,k]<-map read.words<$>getLine
    print$length(intToKString n k )