{-# LANGUAGE BangPatterns #-}

import Control.DeepSeq
import Data.Function
import Control.Applicative
import Data.List
import Data.Bits

main :: IO ()
main = do
 [h,w] <- map read . words <$> getLine
 (!s0,!s1,!s2) <- intoThree h w
 print $ s2-s0

tupInsert :: (Int,Int) -> Int -> (Int,Int,Int)
tupInsert !z (!x,!y)
  | z < x     = force (z,x,y)
  | z < y     = force (x,z,y)
  | otherwise = force (x,y,z)

intoThree :: Int -> Int -> (Int,Int,Int)
intoThree !h !w = minimumBy (compare `on` (\(!s0,!s1,!s2) -> s2-s0)) $ do
  (!x,!y) <- [(h,w), (w,h)]
  let !xd3 = x `div` 3
  !x0 <- [max 0 $ xd3 - 3 .. min x $ xd3 + 4]
  return $! tupInsert (x0 * y) (x - x0) y
  
intoTwo :: Int -> Int -> (Int,Int)
intoTwo !h !w
  | h > w     = go h w
  | otherwise = go w h
  where
    go !long !short
      | even short = force (halfarea,halfarea)
      | otherwise  = force (short * halflong, short * (long - halflong))
      where halflong = long `shiftR` 1
            halfarea = (long*short) `shiftR` 1
