import scala.io.StdIn
import scala.collection.mutable.ListBuffer

object Main extends App {
  val Array(h, w) = StdIn.readLine.split(" ").map(_.toLong)

  val res1 = {
    val list = ListBuffer.empty[Long]
    val m = h / 2L
    val res = (1L to w/2L+1L)./:(Long.MaxValue, Long.MaxValue)((min, i) => {
      val a =( h * i ) 
      list += a
      list += ( m * (w-i) )
      list += ( (h-m) * (w-i) )
      val r1 = list.max - list.min
      list.clear
      val k = (w-i) / 2L
      list += a
      list += ( k * h )
      list += ( (w-i-k) * h )
      val r2 = list.max - list.min
      list.clear
      ( math.min(min._2, r1), math.min(min._2, r2) )
    })
    math.min(res._1, res._2)
  }

  val res2 = {
    val list = ListBuffer.empty[Long]
    val m = w / 2L
    val res = (1L to h/2L+1L)./:(Long.MaxValue, Long.MaxValue)((min, i) => {
      val a = w * i
      list += a
      list += ( m * (h-i) )
      list += ( (w-m) * (h-i))
      val r1 = list.max - list.min
      list.clear
      val k = (h-i) / 2L
      list += a
      list += ( k * w )
      list += ( (h-i-k) * w )
      val r2 = list.max - list.min
      list.clear
      ( math.min(min._1, r1), math.min(min._2, r2) )
    })
    math.min(res._1, res._2)
  }

  val ans = math.min(res1, res2)
  println(ans)
}