import collections

N, K = [int(i) for i in input().split()]



# Kで割ってvalue余る数が1以上key以下にいくつあるか

d = collections.defaultdict(int)

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

    d[i % K] += 1



ans = 0

for a in range(K):

    b = (K - a) % K

    c = (K - a) % K

    if (b + c) % K:

        continue

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

print(ans)
import collections

N, K = [int(i) for i in input().split()]



ans = (N // K) ** 3

if K % 2 == 0:

    ans += ((N + K//2) // K) ** 3

print(ans)

import collections

N, K = [int(i) for i in input().split()]
# Kで割ってvalue余る数が1以上key以下にいくつあるか
d = collections.defaultdict(int)
for i in range(1, N + 1):
    d[i % K] += 1
ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K:
        continue
    ans += d[a] * d[b] * d[c]
print(ans)

import collections

N, K = [int(i) for i in input().split()]
ans = (N // K) ** 3
if K % 2 == 0:
    ans += ((N + K // 2) // K) ** 3
print(ans)

-# Kで割ってvalue余る数が1以上key以下にいくつあるか -d = collections.defaultdict(int) -for i in range(1, N + 1): -    d[i % K] += 1 -ans = 0 -for a in range(K): -    b = (K - a) % K -    c = (K - a) % K -    if (b + c) % K: -        continue -    ans += d[a] * d[b] * d[c] +ans = (N // K) ** 3 +if K % 2 == 0: +    ans += ((N + K // 2) // K) ** 3