local n,k=io.read("n","n")
local t={}
for i=0,k-1 do
    t[i]=0
end
for i=1,n do
    t[i%k]=t[i%k]+1
end

local counter=0
for a=0,k-1 do
    local b=(k-a)%k
    local c=(k-a)%k
    if (b+c)%k==0 then
        counter=counter+t[a]*t[b]*t[c]
    end
end
print(string.format("%d",counter))