import Control.Applicative
import Data.List
import Data.Int
import Debug.Trace

count :: [Int64] -> Int64
count [h, w] =
    let calc :: Int64 -> Int64 -> Int64
        calc ver hor =
            let left = h * ver 
                top = ver * (h - hor)
                bottom = (w - ver) * (h - hor)
                [a, _, b] = sort [left, top, bottom]
                in  b - a
        horizon :: Int64 -> Int64 -> Int64
        horizon ver hor
            | hor > div w 2 = h * w 
            | otherwise = min (horizon ver (hor + 1)) (calc ver hor)
        vertex :: Int64 -> Int64
        vertex ver
            | ver > div h 2 = h * w
            | otherwise = min (vertex (ver + 1)) (horizon ver 1)
        in if (mod h 3) == 0 || (mod w 3) == 0 then 0 else vertex 1
        

main = print =<< count . reverse . sort . (map (\a -> read a :: Int64)) . words <$> getLine
