fun main(args: Array<String>){
    val line: String = readLine() as String
    val nm=line.split(" ")
    val n = nm[0].toLong()
    val m = nm[1].toLong()
    if (n==1L&&m==1L){
        print(1)
    }else if(n==1L||m==1L){
        print(n*m-2)
    }else print((n-2)*(m-2))

}