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