solve :: Int -> Int -> Int
solve n m
  | n == 1 && m == 1 = 1
  | min n m == 1 = max n m - 2
  | otherwise = (n - 2) * (m - 2)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  print $ solve n m