fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    var ary = Array<Long>(k){0}.toMutableList()
    var ans = 0L
    (1..n).forEach {i ->  ary[i%k] += 1}
    (0 until k).forEach { a ->
        var b = (k-a) % k
        var c = (k-a) % k
        if ((b+c) % k != 0) return@forEach
        ans += ary[a] * ary[b] * ary[c]
    }
    println(ans)
}