open Printf
open Scanf

module L =
  struct
    include List

    let rec unfold_right f x =
      match f x with
        None -> []
      | Some (a, b) -> a :: unfold_right f b
  end

let solve n k =
  let f x = if x = 0 then None else Some (x mod k, x / k) in
  L.length @@ L.unfold_right f n

let () =
  scanf "%d %d " solve |> printf "%d\n"
