(println
    (let [[n k] (map #(Integer/parseInt %) (clojure.string/split (read-line) #"\s"))
          n (inc n)]
      (count (for [a (range 1 n)
                   b (range 1 n)
                   c (range 1 n)
                   :when (and (zero? (rem (+ a b) k))
                              (zero? (rem (+ b c) k))
                              (zero? (rem (+ c a) k)))]
               1))))