import Data.List

main = do
  [h, w] <- sort . map read . words <$> getLine :: IO [Int]
  let [w1, w2] = split w
      x = w1 * h
      y = w2 * (h `div` 2)
      z = w2 * ((-) h $ h `div` 2)
      mi = minimum [x, y, z]
      ma = maximum [x, y, z]
  if mod h 3 == 0 || mod w 3 == 0
    then print 0
    else print $ ma - mi

split :: Int -> [Int]
split w
  | mod w 3 == 2 = let x = div w 3
                   in [x+1, w-x-1]
  | otherwise    = [div w 3, w - (div w 3)]
