import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    let ans | n == 1 && m == 1 = 1
            | n == 1 = m - 2
            | m == 1 = n - 2
            | otherwise = (n - 2) * (m - 2)
    print ans