object Main extends App {
	val Array(n, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	def calc(x: Int): Int = {
		x + 3*x*(x-1) + x*(x-1)*(x-2)
	}

	if(k%2 == 1){
		var cnt = 0
		for(x<-1 to n){
			if(x%k == 0){
				cnt += 1
			}
		}
		println(calc(cnt))
	}else{
		val k1 = k/2
		var cnt0 = 0
		var cnt1 = 0
		for(x<-1 to n){
			if(x%k == 0) cnt0 += 1
			else if(x%k1 == 0) cnt1 += 1
		}
		println(calc(cnt1) + calc(cnt0))
	}

}