{-# LANGUAGE CPP #-}
#define MAXNUM maxBound :: Int

import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  putStrLn . show =<< getMin (h, w)


getMin :: (Int, Int) -> IO Int
getMin (h, w) = do
  minWH <- calcDiff (w, h)
  minHW <- calcDiff (h, w)
  return $ min minHW minWH

calcDiff :: (Int, Int) -> IO Int
calcDiff (h, w) = do
  let maxHW = if h < w then w else h
  mins <- forM [1..maxHW - 1] $ \i -> do
    --putStrLn ("splitByWidth " ++ (show i) ++ " (" ++ (show h) ++ " " ++ (show w) ++ ") = "++ (show $ splitByWidth i (h, w)))
    --putStrLn ("splitByHeight " ++ (show i) ++ " (" ++ (show h) ++ " " ++ (show w) ++ ") = "++ (show $ splitByHeight i (h, w)))
    return $ min (splitByWidth i (h, w)) (splitByHeight i (h, w))
   
  return $ minimum mins

splitByWidth :: Int -> (Int, Int) -> Int
splitByWidth n (h, w) = let b = (h - n) `div` 2
                            c = (h - n + 1) `div` 2
                            splits = [n, b, c]
                        in (if h - n > 1 then w * ((maximum splits) - (minimum splits))
                                         else MAXNUM)

splitByHeight :: Int -> (Int, Int) -> Int
splitByHeight n (h, w) = let a = w * n
                             b = (h - n) * (w `div` 2)
                             c = (h - n) * ((w + 1) `div` 2)
                             splits = [a, b ,c]
                         in (if w > 1 then (maximum splits - (minimum splits))
                                      else MAXNUM)