import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [h, w] <- map strToInt . words <$> getLine
    -- 出力
    putStrLn . show $ solve h w

sisyagonyuby ::Int -> Int -> Int
sisyagonyuby m n = if ((fromIntegral n) / (fromIntegral) m) - fromIntegral (n `div` m) >= 0.5 then (n `div` m) + 1 else (n `div` m)

solve :: Int -> Int -> Int
solve h w = if (h `mod` 3) == 0 || (w `mod` 3) == 0
            then 0
            else let maxchoco = max ((*) (sisyagonyuby 3 (max h w)) (min h w)) ((*) (sisyagonyuby 2 (min h w)) ((max h w) - sisyagonyuby 3 (max h w)))
                     minchoco = min ((*) (sisyagonyuby 3 (max h w)) (min h w)) ((*) ((max h w) - sisyagonyuby 3 (max h w)) ((min h w) - sisyagonyuby 2 (min h w)))
                     in maxchoco - minchoco
