import scala.io.StdIn.* def calcFactorInFactorial(n: Long, m: Long): Long = n match case 0L => 0 case _ => n / m + calcFactorInFactorial(n / m, m) @main def main = val Array(n, k, m) = readLine().split(' ').map(_.toLong) val cFactor = calcFactorInFactorial(n, m) - calcFactorInFactorial(k, m) - calcFactorInFactorial(n - k, m) println(cFactor)