main = map read . words <$> getLine >>= \[n, k] -> print (length (patterns n k))
patterns n k  
  | even k    = [(a, b, c) | 
                  a <- [k `div` 2, k .. n], 
                  b <- [k `div` 2, k .. n], 
                  c <- [k `div` 2, k .. n],
                  (a + b) `mod` k == 0,
                  (b + c) `mod` k == 0,
                  (c + a) `mod` k == 0]
  | otherwise = [(a, b, c) |
                  a <- [k, k * 2 .. n], 
                  b <- [k, k * 2 .. n], 
                  c <- [k, k * 2 .. n],
                  (a + b) `mod` k == 0, 
                  (b + c) `mod` k == 0, 
                  (c + a) `mod` k == 0]