object Main extends App {
  val sc = new java.util.Scanner (System.in)
  val N,K = sc.nextInt
  def power(x:Int,p:Int):Int = if(p==0) 1 else x * power(x,p-1)
  def f(n:Int,r:Int):Int = if (n - K <= 0) r+1 else f(n - power(K,r+1),r+1)
  println(f(N,0))
}
