{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= print . uncurry (+) . ( ( ^ 3 ) *** ( ^ 3 ) ) . ( uncurry solveHalf &&& uncurry solveFull ) . mp

solveHalf n k
	| k `mod` 2 == 0 = ( n `div` ( k `div` 2 ) + 1 ) `div` 2
	| otherwise = 0

solveFull = div