main = do
    [h,w] <- map read . words <$> getLine :: IO [Int]
    print $ minimum [cut1 h w, cut1 w h, cut2 h w, cut2 w h]

cut1 h w = maximum ps - minimum ps
    where h1 = (h + 1) `div` 3
          h2 = (h - h1) `div` 2
          h3 = h - h1 - h2
          ps = map (w*) [h1,h2,h3]

cut2 h w = maximum ps - minimum ps
    where h1 = (h + 1) `div` 3
          h2 = h - h1
          w1 = w `div` 2
          w2 = w - w1
          ps = [h1*w, h2*w1, h2*w2]