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

arr = [0]*K

ans = 0

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

    arr[i%K] += 1

for a in range(K):

    b = (K-a) % K

    c = (K-a) % K

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

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

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

arr = [0]*K

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

    arr[i%K] += 1

print((arr[0]**3 if K%2!=0 else arr[0]**3+arr[K//2]**3))
N, K = list(map(int, input().split()))
arr = [0] * K
ans = 0
for i in range(1, N + 1):
    arr[i % K] += 1
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        ans += arr[a] * arr[b] * arr[c]
print(ans)

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

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