'use strict'

const main = (input) => {
    const n = parseInt(input.split(' ')[0])
    const k = parseInt(input.split(' ')[1])
    let num = [];
    for (let i = 1; i <= n; ++i) {
        if(!num[i%k]){
            num[i%k] = 0
        }
        num[i%k]++
    }
    let anw = 0
    for(let a = 0; a < k; ++a){
        let b = (k - a) % k
        let c = (k - a) % k
        if((b + c) % k !== 0) continue
        anw += num[a] * num[b] * num[c]
    }
    console.log(anw)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))