import scala.io.StdIn.readLine

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

  def calc(h: Long, w: Long): Long = {
    1L.to(h / 2).map({ i =>
      val s1 = i * w

      val l = h - i
      val s2 = l / 2 * w
      val s3 = (l - l / 2) * w

      val s4 = w / 2 * l
      val s5 = (w - w / 2) * l

      val min1 = Seq(s1, s2, s3).min
      val max1 = Seq(s1, s2, s3).max

      val min2 = Seq(s1, s4, s5).min
      val max2 = Seq(s1, s4, s5).max

      math.min(max1 - min1, max2 - min2)
    }).min
  }

  println(math.min(calc(h, w), calc(w, h)))

}