"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), K = cin.getInt();
    if (K % 2 == 1) {
        let ans = 0;
        for (let n = 1; n <= N; n++) {
            if (n % K == 0) ans++;
        }
        console.log(ans * ans * ans);
    } else {
        const k2 = Math.floor(K / 2);
        let a0 = 0, a2k = 0;
        for (let n = 1; n <= N; n++) {
            const modK = n % K;
            if (modK == 0) a0++;
            if (modK == k2) a2k++;
        }
        let ans = a0 * a0 * a0 + a2k * a2k * a2k;
        console.log(ans);
    }
}
class Inputer{constructor(t){this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));