
import java.util.Scanner
import math._

object Main extends App {

  val sc = new Scanner(System.in)

  val h, w = sc.nextInt()

  println(min(minimum(h, w), minimum(w, h)))

  def minimum(h: Int, w: Int) : Long = Stream.range(1, h)
    .map(h1 => (h1, (h - h1) / 2, w / 2))
    .map {
      case (h1, h2, w2) => calc(h, w, h1, h2, w2)
    }
    .fold(1L * h * w) {
      case (ans, t) => min(ans, t)
    }

  def calc(h: Int, w: Int, h1 : Long, h2: Long, w2: Long): Long = {
    val s1 = 1L * h1 * w
    val sl2 = 1L * h2 * w
    val sl3 = 1L * (h - h1 - h2) * w
    val sr2 = 1L * (h - h1) * w2
    val sr3 = 1L * (h - h1) * (w - w2)

    var sl = 1L * h * w
    if (sl2 != 0) sl = Seq(s1, sl2, sl3).max - Seq(s1, sl2, sl3).min

    var sr = 1L * h * w
    if (sr2 != 0) sr = Seq(s1, sr2, sr3).max - Seq(s1, sr2, sr3).min

    min(sl, sr)
  }
}
