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

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