calc3 v = v `div` 3

solve h w
  | h <= w = (w - calc3 w) * (h `div` 2) - h * calc3 w
  | h > w  = (h - calc3 h) * (w `div` 2) - w * calc3 h

main = do
  [h,w] <- fmap read <$> words <$> getLine :: IO[Int]
  let v = h * w
  if v `mod` 3 == 0
    then putStrLn . show $ 0
    else putStrLn . show $ solve h w
