
fun main(args: Array<String>) {
	var (h, w) = readLine()!!.split(" ").map{ it.toLong() }
	if (h % 3 == 0L || w % 3 == 0L) {
		println(0)
		return
	}
	var ans = Math.min(h, w)
	for (i in 1..(w - 1)) {
		val a = (w - i) * h
		val b = ((h + 1) / 2) * i
		val c = (h / 2) * i
		val diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))
		ans = Math.min(ans, diff)
	}
	for (i in 1..(h - 1)) {
		val a = (h - i) * w
		val b = ((w + 1) / 2) * i
		val c = (w / 2) * i
		val diff = Math.max(Math.abs(a - b), Math.max(Math.abs(b - c), Math.abs(c - a)))
		ans = Math.min(ans, diff)
	}
	println(ans)
}
