import scala.annotation.tailrec

object Main extends App {
  import scala.io.StdIn._

  val Array(a, n, m) = readLine.trim.split(' ').map(_.toInt)
  println(
    count(a, n, m)
  )
  @tailrec def count(a: Int, n: Int, m: Int, y: Long = 1, res: Int = 0): Int = {
    val x = exponent(a + y, n)
    if (x > m) res
    else count(a, n, m, y + 1, if (sumDigits(x) == y) res + 1 else res)
  }
  def sumDigits(x: Long): Long = {
    x match {
      case 0L ⇒ 0
      case _ ⇒ x % 10 + sumDigits(x / 10)
    }
  }
  def exponent(a: Long, e: Int): Long = {
    e match {
      case 1 ⇒ a
      case _ ⇒ a * exponent(a, e - 1)
    }
  }
}

