fun min(a: Long, b: Long, c: Long) = Math.min(a, Math.min(b, c))

fun max(a: Long, b: Long, c: Long) = Math.max(a, Math.max(b, c))

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toLong)
    if (h % 3 == 0L || w % 3 == 0L) {
        println(0)
        return
    }
    val hhalf = h shr 1
    val d1 = (1 until w).map { x ->
        val wx = w - x
        val wxhalf = wx shr 1
        val s1 = x * h
        val s2 = wx * hhalf
        val s3 = wx * (h - hhalf)
        val s4 = wxhalf * h
        val s5 = (wx - wxhalf) * h
        Math.min(max(s1, s2, s3) - min(s1, s2, s3), max(s1, s4, s5) - min(s1, s4, s5))
    }.min()!!
    val whalf = w shr 1
    val d2 = (1 until h).map { y ->
        val hy = h - y
        val hyhalf = hy shr 1
        val s1 = y * w
        val s2 = hy * whalf
        val s3 = hy * (w - whalf)
        val s4 = hyhalf * w
        val s5 = (hy - hyhalf) * w
        Math.min(max(s1, s2, s3) - min(s1, s2, s3), max(s1, s4, s5) - min(s1, s4, s5))
    }.min()!!
    println(Math.min(d1, d2))
}
