object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w = sc.nextLong()
  if (h % 3 == 0 || w % 3 == 0) {
    println(0)
  } else {
    var ans = h.min(w)
    for (i <- 1 until h.toInt) {
      val a = w * i
      val b = (w/2) * (h-i)
      val c = ((w+1)/2) * (h-i)
      val sMin = a.min(b)
      val sMax = a.max(c)
      ans = ans.min(sMax - sMin)
    }

    for (i <- 1 until w.toInt) {
      val a = h * i
      val b = (h/2) * (w-i)
      val c = ((h+1)/2) * (w-i)
      val sMin = a.min(b)
      val sMax = a.max(c)
      ans = ans.min(sMax - sMin)
    }
    println(ans)
  }
}
