Problem:
 Score : 300 points    Problem Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.
The front and back sides of these cards can be distinguished, and initially every card faces up.  We will perform the following operation once for each square contains a card:   For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.   It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.
Find the number of cards that face down after all the operations.      Constraints  1 \leq N,M \leq 10^9  All input values are integers.         Input Input is given from Standard Input in the following format:  N  M       Output Print the number of cards that face down after all the operations.        Sample Input 1 2 2      Sample Output 1 0  We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.       Sample Input 2 1 7      Sample Output 2 5  After all the operations, all cards except at both ends face down.       Sample Input 3 314 1592      Sample Output 3 496080

Solution (Python):
def myAnswer(N:int,M:int) -> int:
   if(N == 1 and M == 1): return 1
   if(min(N,M) == 1): return max(N,M) - 2
   if(min(N,M) == 2): return 0
   return N*M - (max(N,M) * 2 + (min(N,M) - 2) * 2)

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   print(myAnswer(N,M))
if __name__ == '__main__':
   main()

Solution (Python):
n, m = map(int, input().split())
if n != 1 and m != 1:
    ans = (n-2) * (m-2)
elif n == m == 1:
    ans = 1
elif n == 1 and m != 1:
    ans = m-2
else:
    ans = n-2
print(ans)

Solution (Python):
n,m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
elif n == 2 or m == 2:
    print(0)
else:
    print(n*m-(n*2 + m*2 - 4))

Solution (Python):
N,M = map(int,input().split())
ans = 0
if N == 1 and M == 1:
    ans = 1
elif N == 1:
    ans = M-2
elif M == 1:
    ans = N-2
else:
    ans = (N-2)*(M-2)
print(ans)

Solution (Python):
n, m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 and m == 2:
    print(0)
elif n == 2 and m == 1:
    print(0)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
elif n == 2 or m == 2:
    print(0)
else:
    print((m-2)*(n-2))

Solution (Python):
N,M=list(map(int, input().split()))
if N!=1 and M!=1:
    print((N-2)*(M-2))
elif N==M==1:
    print(1)
elif N==1 and M!=1:
    print(M-2)
else:
    print(N-2)

Solution (Python):
n,m=list(map(int, input().split()))
check=0
if n==1 or m==1:
    if n*m!=1:
        check=max(n,m)-2
print(max((n-2)*(m-2),0)+check)

Solution (Python):
a, b = map(int, input().split())

if a == 1 and b == 1:
    print(1)
elif a ==1 or b == 1:
    print(a * b - 2)
else:
    print((a - 2) * (b - 2))

Solution (Python):
N, M = map(int, input().split())

ans = 0
if N == 1 and M == 1:
    ans = 1
elif N == 1 and M > 1:
    ans = M - 2
elif M == 1:
    ans = N -2
else:
    ans = (N - 2) * (M - 2)

print(ans)

Solution (Python):
N,M = map(int,input().split())
ans = 0
if N == 1 and M == 1:
  ans = 1
elif N == 1:
  ans = M-2
elif M == 1:
  ans = N-2
else:
  ans = N*M-(2*N+2*(M-2))
print(ans)

Solution (Python):
n , m = map(int,input().split())
if n >= 2 and m >=2:
    print((n-2)*(m-2))
elif n == 1 and m != 1:
    print(m-2)
elif m == 1 and n != 1:
    print(n-2)
elif n == 1 and m == 1:
    print(1)

Solution (Python):
N, M = map(int, input().split())









if N == 1 and M == 1:
    print(1)
    exit(0)


if N == 1 or M == 1:
    print(max(N, M)-2)
    exit(0)


print((N-2)*(M-2))

Solution (Python):



N, M = list(map(int, input().split()))


def main():
    if N == 1 and M == 1:
        ans = 1
    elif N == 1 or M == 1:
        ans = max(N, M) - 2
    else:
        ans = (N - 2) * (M - 2)
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
a,b=map(int,input().split())
if a==1 and b==1:
  print(1)
elif a==1:
  print(b-2)
elif b==1:
  print(a-2)
else:
  print((a-2)*(b-2))

Solution (Python):
h,w = map(int,input().split())
if (w == 2 or h == 2):
    print(0)
else:
    print(max(1,h-2)*max(1,w-2))

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(max(n-2,m-2))
else:
    print((n-2)*(m-2))

Solution (Python):
n, m = map(int,input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(max(n,m)-2,0))
else:
    print((n-2)*(m-2))

Solution (Python):
N, M = map(int, input().split())

N, M = min(N, M), max(N, M)
if (N == 1 and M == 1):
    print(1)
elif (N == 1 and M > 1):
    print(M - 2)
else:
    print((N - 2) * (M - 2))

Solution (Python):
def main():
  ans = 0
  n,m = map(int, input().split())
  if n == m == 1:
      ans = 1
  elif n == 1 or m == 1:
      ans = max(n,m)-2
  else:
      ans = (n-2)*(m-2)
  print(ans)

if __name__ == '__main__':
  main()

Solution (Python):
h,w  = map(int,input().split())
if h== 1 and w == 1:
    ans = 0
    
elif h == 1 or w == 1:
    ans = 2
    
else:
    ans = 2*(h-2)+2*(w-2)+4
ans = (h*w) - ans
print(ans)

Solution (Python):
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))

Solution (Python):
N, M = map(int, input().split())
N, M = min(N, M), max(N, M)
if M == 1:
    print(1)
elif N == 1:
    print(M-2)
else:
    print((M-2)*(N-2))

Solution (Python):
n, m = [int(x) for x in input().split()]
print(1 if n == 1 and m == 1 else m - 2 if n == 1 else n - 2 if m == 1 else (n - 2) * (m - 2))

Solution (Python):
n, m = list(map(int, input().split()))
nn = min(n, m)
mm = max(n, m)

if nn == mm:
  if nn == 1:
    print(1)

  else:
    print(max(nn-2, 0) * max(mm-2, 0))
  
else:
  if n != 2:
    print(max(nn-2, 1) * max(mm-2, 1))
  else:
    print(0)

Solution (Python):













n,m = map(int,input().split())

if n==1 and m==1:
    ans = 1
elif n==1 or m==1:
    ans = n*m-2
elif n==2 or m==2:
    ans = 0
else:
    ans = (n-2)*(m-2)

print(ans)

Solution (Python):
n,m = map(int,input().split())
print(abs(n-2)*abs(m-2))

Solution (Python):
n,m = map(int,input().split())
if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)
elif n >= 3 and m==1:
    ans = n-2
elif m >= 3 and n==1:
    ans = m-2
elif n==1 and m==1:
    ans = 1
else:
    ans = 0
print(ans)

Solution (Python):
n,m = map(int,input().split())
if n == 1 and m == 1:
    print (1)
elif n == 1 and m != 1:
    print (m-2)
elif n != 1 and m == 1:
    print (n-2)
else:
    print ((n-2)*(m-2))

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

def main():
    n, m = na()
    if n > 1:
        n -= 2
    if m > 1:
        m -= 2
    print(n * m)

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())

def flip(a,b):
    A = max(a,b)
    B = min(a,b)

    if B >= 2:
        return (A-2) * (B-2)

    if B == 1:
        if A >= 2:
            return A-2
        elif A == 1:
            return 1

a = flip (N, M)
print(a)

Solution (Python):
H,W =[int(i) for i in input().split()]
if H*W==1:
    print(1)
elif H==1 and W!=1:
    print(max(0, W-2))
elif W==1 and H!=1:
    print(max(0, H-2))
else:
    print(max(H-2, 0)*max(W-2, 0))

Solution (Python):
N, M = map(int, input().split())

if(N == 1):
    n = 1
else:
    n = N-2
if(M == 1):
    m = 1
else:
    m = M-2
print(n*m)

Solution (Python):
n,m = map(int,input().split())
if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)
elif n >= 3 and m==1:
    ans = n-2
elif m >= 3 and n==1:
    ans = m-2
elif n==1 and m==1:
    ans = 1
else:
    ans = 0
print(ans)

Solution (Python):
N,M = map(int,input().split())
ura=0





if M==1 and N==1:
  ura +=1
else:
  if M*N==M or M*N==N:
    ura += max(M,N)-2

ura += max(N-2,0) *max(M-2,0)

print(ura)

Solution (Python):
def main():
    n, m = map(int, input().split())
    x, y = min(n, m), max(n, m)
    if x == 1 and y == 1:
        ans = 1
    elif x == 1:
        ans = y - 2
    else:
        ans = (x - 2) * (y - 2)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
if n > 1 and m > 1:
    print((n-2)*(m-2))
    exit()

if n == 1 and m == 1:
    print(1)
    exit()

print(max(n, m)-2)

Solution (Python):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
if n == 1 or m == 1:
    if n == m == 1:
        ans = 1
    else:
        ans = max(n - 2, m - 2)
else:
    ans = (n - 2) * (m - 2)
print(ans)

Solution (Python):
x,y=list(map(int, input().split()))

if x==1 or y==1:
	if x==1 and y==1:
		print(1)
	else:
		print(x*y-2)

else:
	print(((x-2)*(y-2)))

Solution (Python):
if __name__ == "__main__":
    n, m = map(int, input().split())

    ans = 0
    if n > 2 and m > 2:
        ans = (n-2) * (m-2)
    elif n == 1 and m == 1:
        ans = 1
    elif n == 1:
        ans = m - 2
    elif m == 1:
        ans = n - 2

    print(ans)

Solution (Python):
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
  exit(0)

w = n - 2
h = m - 2
if n == 1:
  print(h)
  exit(0)
if m == 1:
  print(w)
  exit(0)
  
print(w*h)

Solution (Python):

from collections import Counter, defaultdict, deque







import sys



ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, m = list(map(int,ipti().split()))

    if n == 1 and m == 1:
        print(1)
    elif n == 1:
        print(m-2)
    elif m == 1:
        print(n-2)
    else:
        print((n-2)*(m-2))

if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
if N==M==1:
  r=1
elif N==1 or M==1:
  r=N+M-3
else:
  r=N*M-2*(N-1)-2*(M-1)
print(r)

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(max(0,max(n,m)-2))
else:
    print((n-2)*(m-2))

Solution (Python):
N, M = map(int, input().split())


if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
elif M > 2 and N > 2:
    print((M - 2) * (N - 2))
else:
    print(0)

Solution (Python):
N,M=map(int,input().split())
print(abs(N-2)*abs(M-2))

Solution (Python):
n, m = (int(x) for x in input().split())
ans = 0
if n >= 3 and m >= 3: ans = (n - 2) * (m - 2)
elif n == 2 or m == 2: ans = 0
elif n == 1 and m == 1: ans = 1
elif n == 1 or m == 1: ans = max(n, m) - 2
else: pass
print(ans)

Solution (Python):
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))

Solution (Python):
n, m = map(int, input().split())
print(abs((n-2)*(m-2)))

Solution (Python):
N,M = map(int,input().split())

ans = abs((N - 2) * (M - 2))

print(ans)

Solution (Python):
n,m = map(int, input().split())

if n==2 or m == 2:
    print(0)
elif n==1 and m == 1:
    print(1)
elif n==1:
    print(m-2)
elif m==1:
    print(n-2)
else:
    print((n-2)*(m-2))

Solution (Python):
n, m = map(int, input().split())
print(abs((n-2)*(m-2)))

Solution (Python):
N,M=map(int,input().split(' '))
if N==1 and  M==1:
    print(1)
elif N==1 or M==1:
    print(max(N,M)-2)
else:
    print(N*M-2*(N+M-2))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

NM = [int(x) for x in input().split()]
NM.sort()
N = NM[0]
M = NM[1]

if N == 1:
    if M >= 3:
        ans = M - 2
    elif M == 1:
        ans = 1
    else:
        ans = 0

    print(ans)
    exit()
elif N == 2:
    print(0)
    exit()

ans = (N - 2) * (M - 2)

print(ans)

Solution (Python):
n, m = map(int, input().split())

if n == m == 1:
    print("1")
elif n == 1:
    print(max(0,m-2))
elif m == 1:
    print(max(0,n-2))
else:
    print((max(0,n-2)) * (max(0,m-2)))

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    
    N, M = Scanner.map_int()
    if N == M == 1:
        print(1)
    elif N == 1:
        print(M-2)
    elif M == 1:
        print(N-2)
    else:
        print((N-2) * (M-2))

    return


if __name__ == "__main__":
    main()

Solution (Python):
def examC():
    N = LI(); N.sort()
    if N[0]==1:
        if N[1]==1:
            ans = 1
        else:
            ans = max(0,N[1]-2)
    else:
        ans = (N[1]-2)*(N[0]-2)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Solution (Python):


N,M=map(int,input().split())
print(abs(((N-2)*(M-2))))

Solution (Python):
N,M = map(int,input().split())

ans = max(0,N-2)*max(0,M-2)
if N == 2 or M == 2:
    print(0)
elif N == 1 or M == 1:
    print(max(1,max(N,M)-2))
else:
    print((N-2)*(M-2))

Solution (Python):
N, M = map(int, input().split())

ans = abs((N - 2)*(M - 2))
print(ans)

Solution (Python):
N, M = map(int, input().split())

if N == 2 or M == 2:
    print(0)
elif N == 1 and M == 1:
    print(1)
elif N == 1 and M > 2:
    print(M - 2)
elif N > 2 and M == 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))

Solution (Python):
n,m = map(int,input().split())
if n == 1 and m == 1:
    ans = 1
elif n == 1 :
    ans = max(0,m - 2)
elif m == 1:
    ans = max(0,n - 2)
else:
    ans = (n - 2) * (m - 2)
print(ans)

Solution (Python):
N, M = map(int, input().split())
print(abs(M-2) * abs(N-2))

Solution (Python):
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
if n == m == 1:
    print(1)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))

Solution (Python):





n,m=map(int,input().split())
if n==1:
  if m==1:
    ans=1
  else:
    ans=1*(m-2)
else:
  if m==1:
    ans=(n-2)*1
  else:
    ans=(n-2)*(m-2)
    
print(ans)

Solution (Python):
N, M = map(int, input().split())

if N == 1 and M != 1:
    print(M - 2)
elif N != 1 and M == 1:
    print(N - 2)
elif N == 1 and M == 1:
    print(1)
else:
    print((N - 2) * (M - 2))

Solution (Python):
N, M = map(int, input().split())

if N == 1 and M == 1:
	print(1)
elif N == 1:
	print(M - 2)
elif M == 1:
	print(N - 2)
else:
	print(N * M - (N + M) * 2 + 4)

Solution (Python):
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(N*M - 2)
elif M == 1:
    print(N*M - 2)
else:
    print(N*M - (N*2) - (M*2) + 4)

Solution (Python):
N, M = map(int, input().split())
if N > M:
  N, M = M, N
if N == 1:
  if M == 1:
    print(1)
  else:
  	print(max(0, M-2))
elif N == 2:
  print(0)
else:
  print((N-2)*(M-2))

Solution (Python):
n, m = map(int, input().split())

if n*m == 1:
    print(1)
elif n*m == 2:
    print(0)
elif n == 1 or m == 1:
    print(max(n, m)-2)
else:
    print(n*m - (n*2+m*2-4))

Solution (Python):
a, b= map(int, input().split())
s = max(a,b)
t = min(a,b)
if s == 2 or t == 2:
    print(0)
elif t == 1:
    if s == 1:
        print(1)
    else:
        print(s - 2)
else:
    print((s-2)*(t-2))

Solution (Python):
n,m=map(int,input().split())
if n>m:
	n,m=m,n
if n==1:
	if m==1:
		print(1)
	else:
		print(m-2)
else:
	print((n-2)*(m-2))

Solution (Python):
a,b=map(int,input().split())
print(0 if a==2 or b==2 else max(1,a-2)*max(1,b-2))

Solution (Python):
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(n*m-2)
else:
    print((n-2) * (m-2))

Solution (Python):
n,m=map(int,input().split())

if n>=2 and m>=2:
    print((n-2)*(m-2))
elif n==1 and m>=2:
    print(m-2)
elif m==1 and n>=2:
    print(n-2)
elif n==1 and m==1:
    print(1)

Solution (Python):
n,m = map(int,input().split())

if n == 1 and m == 1:
    print(1)
    exit()

if n == 1 or m == 1:
    if n > 1:
        ans = max(0,n-2)
    else:
        ans = max(0,m-2)
else:
    ans = n*m - (n*2 + m*2 - 4)

print(ans)

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(max(n,m)-2)
elif n==2 or m==2:
    print(0)
elif n>2 and m>2:
    print((n-2)*(m-2))

Solution (Python):



def solve(n: int, m: int):
    if n == 1 and m == 1:
        return 1
    if n >= 2 and m >= 2:
        return n * m - 2 * (n + m - 2)
    return max(n - 2, 0) + max(m - 2, 0)


def main():
    N, M = map(int, input().split())
    print(solve(N, M))


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
  print(1)
elif n==1 and m>=2:
  print(m-2)
elif m==1 and n>=2:
  print(n-2)
else:
  print((n-2)*(m-2))

Solution (Python):
n, m = map(int, input().split())

if 2 <= n:
    n -= 2
if 2 <= m:
    m -= 2
    
print(n * m)

Solution (Python):
N,M=map(int,input().split())


fc=(N==1 and M==1) 

fs=(N>=3 and M==1) 

fu=(M>=3 and N==1) 

fi=(M>=3 and N>=3) 

ans=(1 if fc else 0)+(N-2 if fs else 0)+(M-2 if fu else 0)+((M-2)*(N-2) if fi else 0)

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
def solve():
  n,m  =(int(i) for i in input().split())
  if n == 1 and m == 1:
    print(1)
  elif n == 1:
    print(m-2)
  elif m== 1:
    print(n-2)
  else:
    print((n-2)*(m-2))
solve()

Solution (Python):
n,m=map(int,input().split())
if m>=2 and n>=2:
    print(m*n-2*m-2*(n-2))
elif m==1 and n==1:
    print(1)
else:
    print(n*m-2)

Solution (Python):
n, m = map(int, input().split())
print(((n-2) if n>=2 else 1) * ((m-2) if m>=2 else 1))

Solution (Python):
n,m=map(int,input().split());print(abs((n-2)*(m-2)))

Solution (Python):
N, M = map(int, input().split())
if N + M == 2:
    print(1)
    exit()
if N == 2 or M == 2:
    print(0)
    exit()
print(max(1, (N-2))*max(1, (M-2)))

Solution (Python):

N, M = map(int, input().split())
if N == 1 or M == 1:
    r = max(N - 2, M - 2)
else:
    r = (N - 2) * (M - 2)

if N + M == 2:
    print(1)
else:
    print(r)

Solution (Python):
import math
import heapq
from collections import Counter




N,M=map(int, input().split())  


if N==1 or M==1:
    if N==1 and M==1:
        print('1')
    else:
        print(N*M-2)    
else:
    print((N-2)*(M-2))

Solution (Python):
n,m=map(int,input().split())
if m>=2 and n>=2:
    print((n-2)*(m-2))
else:
    if n==m==1:
        print(1)
    else:
        print(max(n-2,m-2))

Solution (Python):
N, M = map(int, input().split())
n=0
m=0
if(N!=1):
    n=2
if(M!=1):
    m=2

print(N*M-N*m-M*n+n*m)

Solution (Python):
def main():
    n, m = map(int, input().split())
    print(compute(min(n, m), max(n, m)))


def compute(n, m):
    if n == 1 and m == 1:
        return 1
    if n == 1:
        return max(0, m - 2)
    return (n - 2) * (m - 2)


if __name__ == "__main__":
    main()

Solution (Python):
n,m = map(int,input().split())
if n!=1 and m!=1:
    n-=2
    m-=2
    ans=n*m
    if ans < 0:
        ans=0
    print(ans)
elif n*m==2:
    print(0)
elif n*m==1:
    print(1)
else:
    if n==1:
        m-=2
    elif m==1:
        n-=2
    print(n*m)

Solution (Python):
n, m = map(int,input().split())
if n==m and n==1:
  print(1)
elif min(n,m)==1:
  print(max(n,m)-2)
else:
  print((n-2)*(m-2))

Solution (Python):
N,M=map(int,input().split())
N,M=min(N,M),max(N,M)

if N==M==1:
  print(1)
elif N==1 and M>=2:
  print(M-2)
else:
  print((N-2)*(M-2))

Solution (Python):
import math
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
N,M = map(int,input().split())
if N > 1 and M > 1:
    print((N-2)*(M-2))
elif N==1 and M == 1:
    print(1)
else:
    print(N+M-3)

Solution (Python):
n,m=map(int,input().split());print(max(max(n,m)-2,1)if min(n,m)==1else(n-2)*(m-2))

Solution (Python):
N,M=map(int,input().split())

if N==1 and M==1:
    ans=1
elif N==1 and M>=2:
    ans=M-2
elif M==1 and N>=2:
    ans=N-2
else:
    ans=(N-2)*(M-2)

print(ans)

Solution (Python):
N,M=map(int,input().split())

if N==1 and M==1:
    ans=1
elif N==1 and M==2:
    ans=0
elif N==1 and M>=3:
    ans=M-2
elif N==2 and M==1:
    ans=0
elif N==2 and M==2:
    ans=0
elif M==1 and N>=3:
    ans=N-2
else:
    ans=(N-2)*(M-2)

print(ans)

Solution (Python):
N, M = tuple(map(int, input().split()))
if N == 1 and M == 1:
    print(1)
    exit()

if N == 1:
    print(M - 2)
    exit()
if M == 1:
    print(N - 2)
    exit()

print((M - 2) * (N - 2))

Solution (Python):
n,m = map(int, input().split())
if n == 1 and m==1:
  print(1)
elif n == 1 or m == 1:
  print(max(n-2, m-2))
else:
  print((n-2)*(m-2))

Solution (Python):
n,m = map(int, input().split())
if n == 1 and m==1:
  print(1)
elif n == 1 or m == 1:
  print(max(n-2, m-2, 0))
else:
  print((n-2)*(m-2))

Solution (Python):
H,W = map(int,input().split())
if H==1 and W==1:
    print(1)
elif H%2==0 and W%2==0:
    print((H-2)*(W-2))
elif H%2==0 and W%2!=0:
    print(max(1,(H-2))*max(1,(W-2)))
else:
    print(H*(W-2))

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 and not m==1:
    print(m-2)
elif m==1 and not n==1:
    print(n-2)
else:
    print((m-2)*(n-2))

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 and m>1:
    print(m-2)
elif n>1 and m==1:
    print(n-2)
else:
    print((n-2)*(m-2))

Solution (Python):
n,m=map(int,input().split())
x=(n-2)*(m-2)
if n>=2 and m>=2:
	print(x)
elif n!=1 or m!=1:
	y=max(n,m)
	print(y-2)
else:
	print(1)

Solution (Python):
N,M = map(int,input().split())
if N >= 3 and M >= 3:
    ans = (N-2)*(M-2)
elif N == 2 or M == 2:
    ans = 0
elif N == 1 and M == 1:
    ans = 1
else:
    ans = max(N-2,M-2)

print(ans)

Solution (Python):


import copy
import sys
import math


tmp = input().split()
n,m = list(map(lambda a: int(a), tmp))

if(n==1)and(m==1):
	print(1)
elif(n>=2)and(m>=2):
	print((n-2)*(m-2))
else:
	print(max(n,m)-2)

Solution (Python):
N, M = map(int,input().split())
print(abs(N*M-M*2-N*2+4))

Solution (Python):
n, m = map(int,input().split())
if n-2<0:
    x = 1
else:
    x = n-2
if m-2<0:
    y = 1
else:
    y = m-2
print(x*y)

Solution (Python):
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print((M - 2) * (N - 2))

Solution (Python):
N, M = map(int,input().split())

ans = 0
if N == 1 and M == 1:
    ans = 1
elif N == 1:
    ans = M - 2
elif M == 1:
    ans = N - 2
elif N == 2 or M == 2:
    ans = 0
else:
    ans += (N-2)*(M-2)

print(ans)

Solution (Python):
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
elif n == 1:
  print(m-2)
elif m == 1:
  print(n-2)
else:
  print(n*m-2*m-2*n+4)

Solution (Python):


n,m=map(int,input().split())

if n>=3 and m>=3:
    print((n-2)*(m-2))
elif n==2 or m==2:
    print(0)
else:
    if n==1 and m==1:print(1)
    else:print(max(n,m)-2)

Solution (Python):
N,M = sorted(map(int,input().split()))
if M==1:
    print(1)
elif N==1:
    print(M-2)
else:
    print((N-2)*(M-2))

Solution (Python):
n,m=map(int,input().split())
if n==1 and m==1:
  print(1)
elif n==2 or m==2:
  print(0)
elif n==1 or m==1:
  print(max(n,m)-2)
else:
  print((n-2)*(m-2))

Solution (Python):

n, w = map(int, input().split())
print(abs(n*w-(2*n+2*w-4)))

Solution (Python):

def main():
    n, m = sorted(list(map(int, input().rstrip().split())))
    print(abs((n - 2) * (m - 2)))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    n, m = sorted(list(map(int, input().rstrip().split())))
    if (n, m) == (1, 1):
        print(1)
    elif n == 1:
        print(m - 2)
    elif n == 2:
        print(0)
    else:
        print((n - 2) * (m - 2))


if __name__ == "__main__":
    main()

Solution (Python):
n, m = [int(i) for i in input().split()]
if n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 1 and m >= 2:
    print(m-2)
elif m == 1 and n >= 2:
    print(n-2)
else:
    print(1)

Solution (Python):
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
    exit()

if N == 1 or M == 1:
    print(max(N - 2, M - 2))
else:
    print((N - 2) * (M - 2))

Solution (Python):
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(N, M) - 2)
else:
    print((M-2)*(N-2))

Solution (Python):
n,m = (int(i) for i in input().split())
if n>m:
    n,m = m,n
if n == 1:
    if m == 1:
        print(1)
    elif m>1:
        print(m-2)


else:
    
    print((n-2)*(m-2))

Solution (Python):
N, M = sorted(list(map(int, input().split())))
if N == 1 and M == 1:
	print(1)
elif N == 1 and M > 1:
	print(M-2)
else:
	print((N-2)*(M-2))

Solution (Python):
N, M = sorted(list(map(int, input().split())))
if N == 1 and M == 1:
	print(1)
elif N == 1 and M > 1:
	print(M-2)
else:
	print((N-2)*(M-2))

Solution (Python):

n, m = sorted([ int(v) for v in input().split() ])
if n == 1:
	if m == 1:
		ans = 1
	else:
		ans = m - 2
else:
	ans = (n-2)*(m-2)
print(ans)

Solution (Python):
N,M = map(int, input().split())
if N == 2 or M == 2:
  print(0)
elif N == 1 or M == 1:
  print(max(M,N) - 2 if max(N,M) != 1 else 1)
else :
  print((N-2) * (M-2))

Solution (Python):
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(N * M - 2)
else:
    print((N - 2) * (M - 2))

Solution (Python):
n,m=map(int,input().split())
if n==1:
     if m==1:
          print(1)
     else:
          print(m-2)
elif m==1:
     print(n-2)
else:
     print((m-2)*(n-2))

Solution (Python):

a,b=map(int,input().split())
if a*b==1:
    ans=1
elif (a-1)*(b-1)==0:
    ans=max(a-2,b-2)
else:
    ans=(a-2)*(b-2)
print(ans)

Solution (Python):
N,M=[ int(it) for it in input().split() ]

if ( N>=2 and M>=2 ):
  print ( (N-2)*(M-2) )
elif ( min(N,M) == 1 and max(N,M)>1 ):
  print ( max(N,M)-2 )
else:
  print ( 1 )

Solution (Python):
n,m=map(int,input().split())
if n>m:
    n,m=m,n
if n==1 and m==1:
    print(1)
elif n==1:
    print(m-2)
else:
    print((n-2)*(m-2))

Solution (Python):
N, M = map(int, input().split())
ans = 0
if N == 1 and M == 1:
	print(1)
elif N == 1:
	print(M - 2)
elif M == 1:
	print(N - 2)
else:
	print((N - 2) * (M - 2))

Solution (Python):
n,m = map(int,input().split())
print((n-2)*(m-2) if n>1 and m>1 else abs(abs(n-m)-1))

Solution (Python):
n,m=map(int,input().split())


edge_l=1
if m > 1:
    edge_l+=1
if n > 1:
    edge_l+=1
if m > 1 and n > 1:
    edge_l+=1

edge_l = 1 if edge_l%2==1 else 0

edge_c=3
if n > 1:
    edge_c+=3
edge_c = 1 if edge_c%2==1 else 0

edge_row=edge_l
if m>1:
    edge_row+=edge_l
if m>2:
    edge_row+=(m-2)*edge_c


inner_l = 3
if m > 1:
    inner_l+=3
inner_l = 1 if inner_l%2==1 else 0

inner_c=1 

inner_row=inner_l
if m>1:
    inner_row+=inner_l
if m>2:
    inner_row+=(m-2)*inner_c


total=edge_row
if n>1:
    total+=edge_row
if n>2:
    total+=(n-2)*inner_row
print(total)

Solution (Python):
import numpy as np

N, M = map(int,input().split())

if N == 1:
  if M == 1:
    ans = 1
  else:
    ans = M - 2
elif M == 1:
  ans = N - 2
else:
  ans = (N - 2) * (M - 2)
  
print(ans)

Solution (Python):
N,M = (int(x) for x in input().split())

if N>1 and M>1:
    print((N-2)*(M-2))
else:
    print(abs(abs(N-M)-1))

Solution (Python):
N, M = map(int, input().split())
if N == 1 and M == 1:
  print(1)
elif N == 1 or M == 1:
  print(max(N, M) - 2)
else:
  print((N - 2) * (M - 2))

Solution (Python):
H, W = map(int, input().split())

"""
stage = [[0 for _ in range(W)] for _ in range(H)]
ds = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))

def setv(p, v):
	global stage
	stage[p[1]][p[0]] = v

def getv(p):
	return stage[p[1]][p[0]]

def move(p, d):
	r = (p[0] + d[0], p[1] + d[1])
	if not (0 <= r[0] < W) or not (0 <= r[1] < H):
		return None
	return r

for h in range(H):
	for w in range(W):
		for d in ds:
			nextp = move((w, h), d)
			if not nextp:
				continue
			setv(nextp, (getv(nextp) + 1) % 2)
			

for h in range(H):
	print(*stage[h], sep="")
print()
"""

if 1 == H == W:
	print(1)
	exit()

if 1 == H and not 1 == W:
	print(W - 2)
	exit()

if 1 == W and not 1 == H:
	print(H - 2)
	exit()

print((H - 2) * (W - 2))

Solution (Python):
n,m=[int(i) for i in input().split()]
if n==m==1:
    print(1)
elif min(n,m)==1:
    print(max(n,m)-2)
else:
    print((n-2)*(m-2))

Solution (Python):
N, M = map(int,input().split())
if N == 1 and M == 1:
    print(1)
elif N== 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))

Solution (Python):
N, M = map(int, input().split())
if N >= 2 and M >= 2:
    print(N * M - (N - 2) * 2 - 2 * M)
else:
    if N == 1 and M == 1:
        print(1)
    elif N == 1:
        print(M - 2)
    else:
        print(N - 2)

Solution (Python):
n,m=map(int,input().split())
if n==1:
    if m==1:
        print(1)
    else:
        print(m-2)
elif m==1:
    print(n-2)
elif n==2 or m==2:
    print(0)
else:
    print((n-2)*(m-2))

Solution (Python):
n, m = map(int, raw_input().split())

if n > m: 
	a = n
	n = m
	m = a

if n == 1:
	if m == 1:
		print 1
	else:
		print m - 2 
	exit(0)

black = (n - 2) * (m - 2)
print black