// C - Triangular Relationship
// https://abc108.contest.atcoder.jp/tasks/arc102_a

import scala.io.StdIn.readLine

object Main extends App {

  val Array(n, k) = readLine.split(" ").map(_.toInt)

  val twoPair: Seq[(Int, Int)] = (k to n*2 by k).flatMap(x => (1 to x/2).filter(y => x-y <= n).map(y => (y, x-y)))

  val (sameTwoPair, diffTwoPair) = twoPair.partition(p => p._1 == p._2)
  val sameKeys = sameTwoPair.map(_._1).toSet

  val diffThreeTrio = diffTwoPair.filter(p => sameKeys.contains(p._1) && sameKeys.contains(p._2))

  val count = sameTwoPair.length + (diffThreeTrio.length * 6)

  println(count)

}
