unittest
{
	assert( [ "3 2" ].solve == 9 );
	assert( [ "5 3" ].solve == 1 );
	assert( [ "31415 9265" ].solve == 27 );
	assert( [ "35897 932" ].solve == 114191 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	
	auto ans = 0L;
	auto a = n / k;
	auto b = n / ( k / 2 );
	if( k % 2 ) ans = a ^^ 3;
	else        ans = a ^^ 3 + ( b - a ) ^^ 3;
	return ans;
}
