import Data.Word

main = do
  input <- getLine
  let inputWords = map read $ words  input
      hm = ( inputWords !! 0 )::Word64
      wm = ( inputWords !! 1 )::Word64
  case  (check3 hm wm ) of
    True -> putStr "0"
    False-> putStr $ show $  getR hm wm

getR h' w' | (h' == 1) || (w' == 1) = 1
           |otherwise =
              let h = h' `div` 2
                  w = w' `div` 2
                  delh = h' - h
                  delw = w' - w
                  s1 = delh * delw
                  s2 = delh * w
                  s3 = delw * h
                  dels23 = (max s2 s3 - min s2 s3)
              in s1 - dels23 
  


check3 h w | (h `mod` 3 == 0) || (w `mod` 3 == 0) = True
           | otherwise                            = False


