import Control.Applicative
import Control.Monad

compute :: Int -> Int
compute n = n^3

solver :: Int -> Int -> Int
solver n k
    | odd k     = compute $ length [x | x <- [1..n], x `mod` k == 0]
    | otherwise = h + j
        where m  = k `div` 2
              xs = [x | x <- [1..n], x `mod` k == m]
              ys = [y | y <- [1..n], y `mod` k == 0]
              h  = compute $ length xs
              j  = compute $ length ys

main :: IO ()
main = do
    [n, k] <- (map read) . words <$> getLine
    print $ solver n k
