

import collections 

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



cc=  collections.Counter()

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

	cc[ii % k] +=1



r = 0

for ii in cc:

	if 2*(k - ii) % k == 0:

		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 

		#* cc[(k - ii) % k] 

print(r)
import collections 

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



cc=  collections.Counter()

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

	cc[ii % k] +=1



r = 0

for ii in cc:

	if (- 2*ii) % k == 0:

		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 

		#* cc[(k - ii) % k] 

print(r)
import collections

n, k = list(map(int, input().split(" ")))
cc = collections.Counter()
for ii in range(1, n + 1):
    cc[ii % k] += 1
r = 0
for ii in cc:
    if 2 * (k - ii) % k == 0:
        r += cc[ii] * ((cc[(k - ii) % k]) ** 2)
        # * cc[(k - ii) % k]
print(r)

import collections

n, k = list(map(int, input().split(" ")))
cc = collections.Counter()
for ii in range(1, n + 1):
    cc[ii % k] += 1
r = 0
for ii in cc:
    if (-2 * ii) % k == 0:
        r += cc[ii] * ((cc[(k - ii) % k]) ** 2)
        # * cc[(k - ii) % k]
print(r)

-    if 2 * (k - ii) % k == 0: +    if (-2 * ii) % k == 0: