
solve :: Int -> Int -> Int
solve a b =
  let c = round(fromIntegral a/3)
      d = a - c
      e = b `div` 2
      f = b - e
      ls = [ c*b, e*d, f*d ]
  in maximum ls - minimum ls

main = do
  [h, w] <- map read.words <$> getLine :: IO [Int]
  if h`mod`3 == 0 || w`mod`3 == 3
    then print 0
    else if h > w
      then print $ solve h w
      else print $ solve w h
