import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val ans = (sc.nextInt, sc.nextInt) match {
    case (w, h) if w % 3 == 0 || h % 3 == 0 => 0
    case (w, h) =>
      val init = w min h
      val a = aaa(w, h)
      val b = aaa(h, w)
      init min a min b
  }
  println(ans)

  def aaa(a: Int, b: Int): Int = {
    val xxx = for {
      aa <- List(a / 3, a / 3 + 1)
    } yield {
      val b1 = b / 2
      val b2 = b - b1
      val x1 = aa * b
      val x2 = (a - aa) * b1
      val x3 = (a - aa) * b2
      (x1 max x2 max x3) - (x1 min x2 min x3)
    }
    xxx(0) min xxx(1)
  }
}
