import Data.List

minimize :: Int -> Int -> Int
minimize h w = min (minimize' h w) (minimize' w h)
  where minimize' h w = minimum [ diff (w * i) w (h - i)
                                | i <- [1 .. h - 1] ] 
        half a b
          | a `mod` 2 == 0 || b `mod` 2 == 0 =
              let s = a * b `div` 2 in (s, s)
          | a <= b =
              let hb = b `div` 2 in (a * hb, a * (b - hb))
          | otherwise =
              let ha = a `div` 2 in (b * ha, b * (a - ha))
        diff c a b = let (s, l) = half a b
                         [lt, _, gt] = sort [s, l, c]
                       in gt - lt

main :: IO ()
main = do
  [h, w] <- mapM readIO . words =<< getLine
  print $ minimize h w
