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

cb h w
 | mod h 3 == 0 || mod w 3 == 0 = 0
 | h==1 || w==1 = 1
 | otherwise = min (maximum [s1,s2,s3] - minimum [s1,s2,s3]) (maximum [s1',s2',s3'] - minimum [s1',s2',s3'])
 where
  s1 = (div (max h w) 3 + 1) * (min h w)
  s2 = (div (min h w) 2) * (max h w - (div (max h w) 3 + 1))
  s3 = ((min h w) - (div (min h w) 2)) * (max h w - (div (max h w) 3 + 1))
  s1' = (div (max h w) 3) * (min h w)
  s2' = (div (min h w) 2) * (max h w - (div (max h w) 3))
  s3' = ((min h w) - (div (min h w) 2)) * (max h w - (div (max h w) 3))