module Main where

import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    [n, k] <- fmap read . words <$> getLine :: IO [Int]
    if odd k
        then do
            let s = length [x | x <- [1 .. n], x `mod` k == 0]
            print $ s ^ 3
        else do
            let s = length [x | x <- [1 .. n], x `mod` k == 0]
            let t = length [x | x <- [1 .. n], x `mod` k == k `div` 2]
            print $ s ^ 3 + t ^ 3