solver::Int->Int-> Int
solver h w = case (mod h 2,mod w 3) of
            (0,0) -> 0
            (0,1) -> div h 2
            (0,2) -> div h 2
            (1,0) -> 0
            (1,1) -> if (div (w-1) 3)>= (div (h-1) 2) then (div (w-1) 3)*2 +1 else (div (w-1) 3)+1+(div (h-1) 2)
            (1,2) -> max ((div (h-1) 2) + (div (w-2) 3) + 1) ((div (w-2) 3)*3 +1 )

solver2::Int -> Int -> Int
solver2 h w = if (mod h 3 == 0)||(mod w 3 ==0) then 0 else min (solver h w)(solver w h)

main::IO()
main =do
  hwc<-getLine
  let h:w:[]=map read (words hwc)
  print (solver2 h w)
