
main = do
  (h:w:_) <- return . (map read) . words =<< getLine
  print $ minimum [h * f (mod h 3),w * f (mod w 3), g w h, g h w]

  where
    f 0 = 0
    f n = 1

    g w h = minimum [mm [h*x, hf*(w-x), (h-hf)*(w-x)] |x<-[1..w-1]]
      where
        hf = div h 2

    mm xs = maximum xs - minimum xs
