program Triangular_Relationship
	implicit none
	integer(8) ans,m
	integer n,k,a

	read *, n, k
	ans = 0

	do a=1, k
		if (mod(a*2,k) == 0) ans = ans + (((n-a)/k)+1)**2
	enddo

	ans = ans * (n/k)

	do a = 1, mod(n,k)
		if (mod(a*2,k) == 0) ans = ans + (((n-a)/k)+1)**2
	enddo

    print *,ans

end program Triangular_Relationship

