local n, k = io.read("*n", "*n")
local r = n // k
if k % 2 == 0 then
  if k <= (n % k) * 2 then
    r = r * r * r + (r + 1) * (r + 1) * (r + 1)
  else
    r = 2 * r * r * r
  end
else
  r = r * r * r
end
print(r)
