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



mod_ls = [0] * k

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

    rest = i % k

    mod_ls[rest] += 1



ans = 0

for i in range(1,k):

    first = i

    second = k - i

    third = k - second

    if (first + third) % k == 0:

        ans += mod_ls[first] * mod_ls[second] * mod_ls[third]

ans += mod_ls[0] ** 3

print(ans)

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

n_O = 0

n_E = 0

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

    if (2*i) % k == 0:

        if (2*i//k)%2 == 0:

            n_E += 1

        else:

            n_O += 1

print((n_E**3+n_O**3))

n, k = list(map(int, input().split()))
mod_ls = [0] * k
for i in range(1, n + 1):
    rest = i % k
    mod_ls[rest] += 1
ans = 0
for i in range(1, k):
    first = i
    second = k - i
    third = k - second
    if (first + third) % k == 0:
        ans += mod_ls[first] * mod_ls[second] * mod_ls[third]
ans += mod_ls[0] ** 3
print(ans)

n, k = list(map(int, input().split()))
n_O = 0
n_E = 0
for i in range(1, n + 1):
    if (2 * i) % k == 0:
        if (2 * i // k) % 2 == 0:
            n_E += 1
        else:
            n_O += 1
print((n_E**3 + n_O**3))

-mod_ls = [0] * k +n_O = 0 +n_E = 0 -    rest = i % k -    mod_ls[rest] += 1 -ans = 0 -for i in range(1, k): -    first = i -    second = k - i -    third = k - second -    if (first + third) % k == 0: -        ans += mod_ls[first] * mod_ls[second] * mod_ls[third] -ans += mod_ls[0] ** 3 -print(ans) +    if (2 * i) % k == 0: +        if (2 * i // k) % 2 == 0: +            n_E += 1 +        else: +            n_O += 1 +print((n_E**3 + n_O**3))