import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    let (d,m) = n `divMod` k
        ans | odd k = d^3
            | even k = d^3 + e^3
            where e = d + if 1 <= m && m < k `div` 2 then 0 else 1
    print ans