fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toLong)

    val result = when (n * m) {
        1L, 3L -> 1L
        2L, 4L, 6L -> 0L
        else -> when {
            n == 1L || m == 1L -> n * m - 2
            else -> m * n - (m * 2 + (n - 2) * 2)
        }
    }
    println(result)
}

