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

count :: [Int64] -> Int64
count [h, w] =
    let 
        calc :: Int64 -> Int64
        calc ver =
            let left = h * ver
                top = ver * (div h 2)
                bottom = ver * (h - (div h 2))
                [a, _, b] = sort [left, top, bottom]
                in  b - a
        calc_ ver =
            let top = w * ver
                left = ver * (div w 2)
                right = ver * (w - (div w 2))
                [a, _, b] = sort [left, right, top]
                in  b - a

        cross :: Int64 -> Int64
        cross ver
            | ver > div h 2 = h * w
            | otherwise = min (cross (ver + 1)) (calc ver)
        crossed :: Int64 -> Int64
        crossed ver
            | ver > div w 2 = w * h
            | otherwise = min (crossed (ver + 1)) (calc_ ver)
        parallel :: Int64
        parallel = if (mod h 3) == 0 || (mod w 3) == 0 then 0 else w
        in min (cross 1) (min parallel $ crossed 1)
        

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