fun main(args: Array<String>) {
    abc108c()
}

fun abc108c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    val restZero = (1..n).count() { it % k == 0 }.toDouble()
    val restHalvedK = (if (k % 2 == 0) (1..n).count { it % k == k / 2 } else 0).toDouble()

    println(Math.pow(restZero, 3.0).toLong() + Math.pow(restHalvedK, 3.0).toLong())
}
