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

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