

import collections 

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



cc=  collections.Counter()

left = n % k

for ii in range(k):

	cc[ii] += n / k

	if 0<ii <= left:

		cc[ii] += 1





r = 0

for ii in cc:

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

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



print(r)


import collections 

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



left = n % k

cc = [0] * k

for ii in range(k):

	cc[ii] += n / k

	if 0<ii <= left:

		cc[ii] += 1





r = 0

for ii in range(len(cc)):

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

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



print(r)
import collections

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

import collections

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

-cc = collections.Counter() +cc = [0] * k -for ii in cc: +for ii in range(len(cc)):