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



if K == 1:

    print((N**3))

    exit()



ans = 0

for k in range(K):

    if (k * 2) % K != 0:

        continue

    M = (N // K) - (1 if k == 0 else 0)

    if N % K >= k:

        M += 1

    ans += M**3

print(ans)

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



M = N // K

ans = M * (M - 1) * (M - 2) + M * (M - 1) * 3 + M



if K % 2 == 0:

    if N % K >= K // 2:

        M += 1

    ans += M * (M - 1) * (M - 2) + M * (M - 1) * 3 + M



print(ans)

N, K = list(map(int, input().split()))
if K == 1:
    print((N**3))
    exit()
ans = 0
for k in range(K):
    if (k * 2) % K != 0:
        continue
    M = (N // K) - (1 if k == 0 else 0)
    if N % K >= k:
        M += 1
    ans += M**3
print(ans)

N, K = list(map(int, input().split()))
M = N // K
ans = M * (M - 1) * (M - 2) + M * (M - 1) * 3 + M
if K % 2 == 0:
    if N % K >= K // 2:
        M += 1
    ans += M * (M - 1) * (M - 2) + M * (M - 1) * 3 + M
print(ans)

-if K == 1: -    print((N**3)) -    exit() -ans = 0 -for k in range(K): -    if (k * 2) % K != 0: -        continue -    M = (N // K) - (1 if k == 0 else 0) -    if N % K >= k: +M = N // K +ans = M * (M - 1) * (M - 2) + M * (M - 1) * 3 + M +if K % 2 == 0: +    if N % K >= K // 2: -    ans += M**3 +    ans += M * (M - 1) * (M - 2) + M * (M - 1) * 3 + M