N, K = list(map(int, input().split()))

num = [0 for _ in range(K)]

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

    num[i % K] += 1

ans = 0

for a in range(K):

    b = (K - a) % K

    c = (K - a) % K

    if (b + c) % K == 0:

        ans += num[a] * num[b] * num[c]

print(ans)





N, K = list(map(int, input().split()))

num = [0 for _ in range(K)]

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

    num[i % K] += 1

ans = 0

if K % 2 == 0:

    ans += num[0] ** 3 + num[K // 2] ** 3

else:

    ans += num[0] ** 3

print(ans)







N, K = list(map(int, input().split()))
num = [0 for _ in range(K)]
for i in range(1, N + 1):
    num[i % K] += 1
ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        ans += num[a] * num[b] * num[c]
print(ans)

N, K = list(map(int, input().split()))
num = [0 for _ in range(K)]
for i in range(1, N + 1):
    num[i % K] += 1
ans = 0
if K % 2 == 0:
    ans += num[0] ** 3 + num[K // 2] ** 3
else:
    ans += num[0] ** 3
print(ans)

-for a in range(K): -    b = (K - a) % K -    c = (K - a) % K -    if (b + c) % K == 0: -        ans += num[a] * num[b] * num[c] +if K % 2 == 0: +    ans += num[0] ** 3 + num[K // 2] ** 3 +else: +    ans += num[0] ** 3