object Main extends App {
  import scala.io.StdIn._
  val Array(n, m, k) = readLine.trim.split(' ').map(_.toLong)
  val base = (n % 10).toInt
  val nm = power(n % 10, m)
  val first = Array.fill(10){-1}
  var whileFirst = -1
  var loopLen = -1
  first(base) = 0
  for (i ← 1 to 11 if whileFirst == -1) {
    if (first(base * power(nm, i) % 10) == -1) {
      first(base * power(nm, i) % 10) = i
    }else {
      whileFirst = first(base * power(nm, i) % 10)
      loopLen = i - whileFirst
    }
  }
  val f = (0 until whileFirst).map(i ⇒ base * power(nm, i) % 10)
  val l = (0 until loopLen).map(i ⇒ base * power(nm, whileFirst + i) % 10)
  val r = (0L until (k - whileFirst) % loopLen).map(i ⇒ base * power(nm, whileFirst + i) % 10)
  println(f.sum + l.sum * ((k - whileFirst) / loopLen) + r.sum)
  def power(base: Long, exp: Long): Int = {
    exp match {
      case 0 ⇒ 1
      case 1 ⇒ (base % 10).toInt
      case _ ⇒ power(base * base % 10, exp / 2) * power(base, exp % 2) % 10
    }
  }
}
