main = do
 [h,w] <- map read . words <$> getLine
 print (min (cb h w) (cb w h))

cb :: Integer -> Integer -> Integer
cb x y = min (maximum [s1,s2,s3] - minimum [s1,s2,s3]) (maximum [s1,s2',s3'] - minimum [s1,s2',s3'])
 where
  x1 = round ((fromIntegral x) / 3)
  x2 = x - x1
  y1 = div y 2
  y2 = y - y1
  x1' = div x2 2
  x2' = x2 - x1'
  s1 = x1 * y
  s2 = x2 * y1
  s3 = x2 * y2
  s2' = x1' * y
  s3' = x2' * y