from math import *

n,k=list(map(int,input().split()))

dict1={}

flag=0

ans=0

if(k%3==0):

    flag=1

for i in range(1,n+1):

    try:

        dict1[i%k]+=1

    except:

        KeyError

        dict1[i%k]=1

dict2={}

for i in list(dict1.keys()):

    try:

        if(dict2[i]==1):

            a=1

    except:

        KeyError

        if((i+i)%k==0):

            ans+=dict1[i]*dict1[i]*dict1[i]

            dict2[i]=1

            dict2[k-i]=1

print(ans)
from math import *

n,k=list(map(int,input().split()))

dict1={}

flag=0

ans=0

if(k%3==0):

    flag=1

for i in range(1,n+1):

    try:

        dict1[i%k]+=1

    except:

        KeyError

        dict1[i%k]=1

for i in list(dict1.keys()):

    if((i+i)%k==0):

        ans+=dict1[i]*dict1[i]*dict1[i]



print(ans)
from math import *

n, k = list(map(int, input().split()))
dict1 = {}
flag = 0
ans = 0
if k % 3 == 0:
    flag = 1
for i in range(1, n + 1):
    try:
        dict1[i % k] += 1
    except:
        KeyError
        dict1[i % k] = 1
dict2 = {}
for i in list(dict1.keys()):
    try:
        if dict2[i] == 1:
            a = 1
    except:
        KeyError
        if (i + i) % k == 0:
            ans += dict1[i] * dict1[i] * dict1[i]
            dict2[i] = 1
            dict2[k - i] = 1
print(ans)

from math import *

n, k = list(map(int, input().split()))
dict1 = {}
flag = 0
ans = 0
if k % 3 == 0:
    flag = 1
for i in range(1, n + 1):
    try:
        dict1[i % k] += 1
    except:
        KeyError
        dict1[i % k] = 1
for i in list(dict1.keys()):
    if (i + i) % k == 0:
        ans += dict1[i] * dict1[i] * dict1[i]
print(ans)

-dict2 = {} -    try: -        if dict2[i] == 1: -            a = 1 -    except: -        KeyError -        if (i + i) % k == 0: -            ans += dict1[i] * dict1[i] * dict1[i] -            dict2[i] = 1 -            dict2[k - i] = 1 +    if (i + i) % k == 0: +        ans += dict1[i] * dict1[i] * dict1[i]