main = interact $ show . sol . map read . words

sol [h,w] 
  | h `mod` 3==0 || w `mod` 3==0  = 0
  | even h && odd w               = f h w
  | even w && odd h               = f w h
  | even h && even w              = f (min h w) (max h w)
  | otherwise                     = g (min h w) (max h w)

f x y = min (x*a - (x `div` 2)*(y-a)) ((x `div` 2)*(y-a') - x*a')
  where
  a = ceiling $ fromIntegral y/3
  a' = floor $ fromIntegral y/3

g x y = min (abs $ x*a - (x `div` 2)*(y-a)) (abs $ (x `div` 2 + 1)*(y-a') - x*a') 
  where
  a = ceiling $ fromIntegral y/3
  a' = floor $ fromIntegral y/3
