main = do
  l <- getLine
  let [n,k] = map read $ words l
  print $ abc108c n k

abc108c n k = sum
  [ count a b c
  | a <- [1..n]
  , b <- [a..n]
  , mod (a+b) k == 0
  , c <- [b..n]
  , mod (b+c) k == 0
  , mod (c+a) k == 0
  ]

count a b c
  | a == b && b == c = 1
  | a == b || b == c || c == a = 3
  | True = 6