import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val H = sc.nextInt()
    val W = sc.nextInt()

    // できるだけ等しくなるようにカットして、２つの面積を返す
    def cutEvenly(h: Long, w: Long): (Long, Long) = {
      val hor = (h / 2 * w, (h - h / 2) * w)
      val ver = (w / 2 * h, (w - w / 2) * h)
      if (abs(hor._1 - hor._2) < abs(ver._1 - ver._2))
        hor
      else
        ver
    }

    def cutBig(short: Long, big: Long, w: Long) = {
      val a = short * w
      val (b, c) = cutEvenly(big, w)
      max(max(a, b), c) - min(min(a, b), c)
    }

    // 一回めのカットが水平方向
    def minCut_hor(h: Int, w: Long): Long = {
      (1 until h map { i =>
        val h1 = i.toLong
        val h2 = h - i
        if (h1 > h2)
          cutBig(h2, h1, w)
        else
          cutBig(h1, h2, w)
      }).min
    }

    val ans = min(minCut_hor(H, W), minCut_hor(W, H))
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  private class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}
