function Main(input) {
	let input = input.split("　");
	let n = parseInt(input[0], 10);
  	let k = parseInt(input[1], 10);
  	let count;
  	for(A = 1; A <= n; A++){
    	for(B = 1; B <= n; B++){
         	for(C = 1; C <= n; C++){
				let AB = a+b;
              	let BC = b+c;
              	let AC = a+c;
              	if(AB % k === 0 && BC % k === 0 && AC % k === 0){
					count++;
                }
            } 
    	}
	}
  	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));