'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(Number)

  const N = input[0]
  const K = input[1]
  let ans = 0
  if (K % 2 === 1) {
    // odd
    for (let i = 1; i <= N; i++) {
      if (i % K === 0) ans++
    }
    ans = Math.pow(ans, 3)
  } else {
    // even
    let tmp1 = 0
    let tmp2 = 0
    for (let i = 1; i <= N; i++) {
      const remain = i % K
      if (remain === 0) tmp1++
      if (remain === K / 2) tmp2++
    }
    ans += Math.pow(tmp1, 3)
    ans += Math.pow(tmp2, 3)
  }

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
