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