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):
n, m = map(int, input().split())
ans = -1
inp = sorted([n, m])
if inp[0] == 1:
    if inp[1] == 1:
        ans = 1
    else:
        ans = inp[1] - 2
else:
    ans = (inp[0] - 2) * (inp[1] - 2)
print(ans)

Solution (Python):
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)
elif n == 2 and m == 2:
    print(0)
else:
    print((n-2) * (m-2))

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

if N == 0 or M == 0 or 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)
elif N <= 2 or M <= 2:
    print((N - 2) * 2 + (M - 2) * 2)
else :
    print((N - 2) * (M - 2))

Solution (Python):
N,M = map(int,input().split())
if N>M: N,M = M,N
if N == 1:
    print(abs(2-M))
elif N == 2:
    print(0)
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:
    print(M-2)
elif M<2:
    print(N-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 and M>1:
    print(M-2)
elif N>1 and M==1:
    print(N-2)
else:
    print((N-2)*(M-2))

Solution (Python):


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

    if n >= 2 and m >= 2:
        cards = n * m - (n * 2 + (m - 2) * 2)
        print(cards)
    elif n == 1 and m >= 2:
        print(m - 2)
    elif n >= 2 and m == 1:
        print(n - 2)
    else:
        print('1')
    

if __name__ == '__main__':
    main()

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

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

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

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


i = max((N - 2), 0) * max((M - 2), 0)
s = max((M - 2), 0) if N == 1 else 0
v = max((N - 2), 0) if M == 1 else 0
c = 1 if N == 1 and M == 1 else 0


print(i+s+c+v)

Solution (Python):

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

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

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 > m: n,m = m,n
if n == 1:
    if m == 1:
        print(1)
    else:
        print(m - 2)
else:
    print(max(0, n - 2) * max(0, m - 2))

Solution (Python):
n, m = list(map(int, input().split()))
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())
print(abs(N - 2) * abs(M - 2))

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

a = min(n, m)
b = max(n, m)

if a >= 3:
    print((a-2)*(b-2))
elif a == 2:
    print(0)
elif a == 1:
    if b >= 3:
        print(b-2)
    elif b == 2:
        print(0)
    elif b == 1:
        print(1)

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

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

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

Solution (Python):

def main():
    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))

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 > 1:
    print(M - 2)
elif N > 1 and M == 1:
    print(N - 2)
else:
    print((M - 2) * (N - 2))

Solution (Python):
a=list(map(int,input().split(' ')))
M=max(a[0],a[1])
N=min(a[0],a[1])

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

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):
n, m = list(map(int, input().split()))
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 >=3 and M >= 3: print((N-2) * (M-2))
elif N < 3 and M < 3: print(1) if (N * M) % 2 else print(0)
else:
    N, M = max(N,M), min(N,M)
    if M == 1: print(N - 2)
    else: print(0)

Solution (Python):
N,M = map(int,input().split())
if N >= 2 and M >= 2:
    ans = (N - 2) * (M - 2)
elif N == 1 and M >= 2:
    ans = (M - 2)
elif N >= 2 and M == 1:
    ans = (N - 2)
else:
    ans = 1
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):
def line_input(f, type):
    return f(map(type, input().split(" ")))

n, m = line_input(tuple, int)

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):


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*B-2*A-2*B+4)

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 N >= 2 and M == 1:
	print(N-2)
else:
	print((N-2)*(M-2))

Solution (Python):

def main():
    nm = [int(i) for i in input().split()]

    nm.sort()
    
    if nm[0] == 1 and nm[1] == 1:
        
        print(1)
    elif nm[0] == 1 and nm[1] == 2:
        
        print(2)
    elif nm[0] == 1 and nm[1] > 2:
        
        print(nm[1] - 2)
    elif nm[0] == 2:
        
        print(0)
    elif nm[0] > 2 and nm[1] > 2:
        
        print((nm[0]-2) * (nm[1]-2))
    else:
        raise ValueError


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
ans = 0
if N == M == 1:
	ans = 1
elif N == 1 and M >= 2:
	ans = M - 2
elif N >= 2 and 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 and M >= 2:
	ans = M - 2
elif N >= 2 and 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 == M == 1:
	ans = 1
elif N == 1 and M >= 2:
	ans = M - 2
elif N >= 2 and M == 1:
	ans = N - 2
else:
	ans = (N - 2) * (M - 2)
print(ans)

Solution (Python):
def main():
    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))

main()

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())
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())

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

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

if b==1:
  if a==1:
    print(1)
  else:
    print(a-2)

elif b==2:
  print(0)
  
else:
  print((a-2)*(b-2))

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

if N==1 or M==1:
    if N==1 and M==1:
        print(1)
    else:
        if N < M:
            N, M = M, N
        print(N-2)

else:
    print((N*M) - N*2 - M*2 + 4)

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

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

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

print(abs(n-2) * abs(m-2))

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

if n == 1 or m == 1:
	print abs(n*m-2)

elif n==2 or m==2:
	print 0

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

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):
m , n = map(int,input().split(" "))


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

Solution (Python):
N, M = map(int, input().split())
ans = 0
if 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:
  ans = (N-2) * (M-2)
print(ans)

Solution (Python):

"""
Created on Wed Jun 13 17:57:26 2018


N*Mで裏返しのカード
あるマスとその8近傍のカードを裏返す
全てのマスに同様の処理を行う
表のカードの枚数を出力する


入力
1 7

出力
5


@author: Yuya
"""

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

if N > 1 and M > 1:
    print((N-2)*(M-2))
else:
    ans1 = N-2
    ans2 = M-2
    ans = abs(ans1*ans2)
    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(N*M -2)

elif N == 2 or M == 2:
    print(0)

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

Solution (Python):

line=input()
line=line.rstrip().split(" ")
N1=int(line[0])
N2=int(line[1])
print(abs(N1*N2-((N1-2)*2+(N2-2)*2)-4))

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

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

N,M = min(N,M),max(N,M)
Ans = 0
if N==1 and M==1:
    Ans = 1
elif N==1:
    Ans = M-2
elif N==2:
    Ans = 0
else:
    Ans = (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))
if N == 1 and M == 1:
    print(1)
if N == 1 and M >= 2:
    print(M - 2)
if N >= 2 and M == 1:
    print(N - 2)

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

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

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

Solution (Python):
n,m = input().split()
N=int(n)
M=int(m)
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):
def m():
    n, m = map(int, input().split())
    if n == 1 and m == 1:
        return 1
    if n == 1:
        return m-2
    if m == 1:
        return n-2
    if n == 2 or m == 2:
        return 0
    return (m-2) * (n-2)

print(m())

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:
    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((((N==1)^(M==1))*-2 + 1)*(N-2)*(M-2))

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

def main():
    n = N - 1
    m = M - 1
    if not n and not m:
        ans = 1
    elif not n or not m:
        ans = n + m -1
    else:
        ans = (n - 1) * (m - 1)
    print(ans)

if __name__ == "__main__":
    main()

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 > M: N,M = M,N
if N == M == 1:
    print(1)
elif N == 1:
    print(M-2)
elif N == 2:
    print(0)
else:
    print((N-2)*(M-2))

Solution (Python):
N, M = map(int, raw_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*N - 2*M + 4)

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)*abs(m-2))

Solution (Python):
N,M = map(int, input().split())
if N > M:
    N,M = M,N
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, raw_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):
def c_flip(N, M):
    if N == 1 and M == 1:
        ans = 1  
    elif min(N, M) == 1:  
        
        ans = max(N, M) - 2
    else:
        
        ans = (N - 2) * (M - 2)
    return ans

N,M = [int(i) for i in input().split()]
print(c_flip(N, M))

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

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

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

if N > 1 and M > 1:
    print(N * M - (N - 1) * 2 - (M - 1) * 2)
elif 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):
    N -= 2
if (M > 1):
    M -= 2
print(N * M)

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

Solution (Python):
n, m = sorted(map(int, raw_input().split()))
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())
if 2<=n and 2<=m:
    print((m-2)*(n-2))
elif n==1 and m==1:
    print(1)
elif n==1 and 2<=m:
    print(m-2)
elif m==1 and 2<=n:
    print(n-2)

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

if N>M:
    tmp=N
    N=M
    M=tmp

if N==1:
    if M==2:
        print(0)
    elif M==1:
        print(1)
    else:
        print(M-2)
elif N==2:
    print(0)
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:  
    if n > m:
        print(n-2)
    else:
        print(m-2)
else:                   
    print((n-2)*(m-2))

Solution (Python):
n, m = input().split()
n = int(n)
m = int(m)
ans = 0
if min(m, n) != 1:
    ans = max(n * m - (2 * n + 2 * m - 4), 0)
else:
    ans = max(max(n, m) - 2, 1)
print(ans)

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

if N==1 or M==1:
    if N==1 and M==1:
        print(1)
    else:
        print(max(N,M)-2)
else:
    print((M-2)*(N-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(max(0,M-2))
else:
    print((N-2)*(M-2))

Solution (Python):

n, m = sorted([int(s) for s in input().split()])
if n == m == 1:
    sol = 1
elif n == 1:
    sol = m - 2
elif n == 2:
    sol = 0
else:
    sol = (n - 2) * (m - 2)
print(sol)

Solution (Python):
n, m = input().split()
n = int(n)
m = int(m)
ans = 0
if min(m, n) != 1:
    ans = max(n * m - (2 * n + 2 * m - 4), 0)
else:
    ans = max(max(n, m) - 2, 1)
print(ans)

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

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

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

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)
elif n == 1 and m == 1:
    print(1)
else:
    print(max(n, m) - 2)

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

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 == 1 and M == 1:
    print(1)
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((N-2)*(M-2))

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

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

Solution (Python):
def main():
    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*M - (N*2 + M*2 - 4 ))
    
if __name__=="__main__":
    main()

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>1 and m>1:
    print((n-2)*(m-2))
elif n ==1 and m >1:
    print(m-2)
elif n >1 and m==1:
    print(n-2)
else:
    print(1)

Solution (Python):
n, m = list(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):
num = 0
nm1 = [int(x) for x in input().split()]

if nm1[0] == 1 and nm1[1] == 1:
    print(nm1[0])
elif nm1[0] == 1:
    print(nm1[1]-2)
elif nm1[1] == 1:
    print(nm1[0]-2)
else:
    print((nm1[0]-2)*(nm1[1]-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 N != 1 and 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())
print(abs(N-2)*abs(M-2))

Solution (Python):
from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    
    
    
    
    
    
    
    
    
    
    
    

    MIN = min(N, M)
    MAX = max(N, M)
    if MIN == 1 and MAX == 1:
        result = 1
    elif MIN == 1:
        result = MAX - 2
    elif MIN == 2:
        result = 0
    else:
        result = (MIN - 2) * (MAX - 2)
    print(result)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n,m=list(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>M:
    temp = N
    N = M
    M = temp




if N == 1:
    if M == 1:
        ans = 1
    else:
        ans = M-2
elif N == 2:
    ans = 0
else:
    ans = M*N - 2*(M+N) +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(n*m-2)

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

Solution (Python):
K = input().split()
N = int(K[0])
M = int(K[1])

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

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

if (n == 1) & (m == 1):
    print(1)
elif (n == 1) | (m == 1):
    print(max([n, m]) - 2)
elif (n == 2) | (m == 2):
    print(0)
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 n == 2 or m == 2:
    print(0)
else:
    print((n - 2) * (m - 2))

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

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

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

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

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

n = int(n)
m = int(m)

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

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())

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())
if n > 1 and m > 1:
    print((n-2)*(m-2))
else:
    if n == 1 and m == 1:
        print(1)
    else:
        if n == 1:
            print(m-2)
        else:
            print(n-2)

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

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

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

Solution (Python):
def calc(n, m):
    if n == 1:
        if m == 1:
            return 1
        if m == 2:
            return 0
        if m >= 3:
            return m - 2
    elif n == 2:
        return 0
    else:
        if m == 1:
            return n - 2
        elif m == 2:
            return 0
        else:
            return (n - 2) * (m - 2)


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


if __name__ == '__main__':
    main()

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

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

print(r)

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 == 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 = list(map(int, input().split()))
if min(n, m) == 1:
    if max(n, m) == 2:
        ans = 2
    elif max(n, m) == 1:
        ans = 1
    else:
        ans = max(n, m) - 2
elif min(n, m) == 2:
    ans = 0
else:
    ans = (n - 2) * (m - 2)
print(ans)

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

if N == 1:
    n = N
else:
    n = N - 2
if M == 1:
    m = M
else:
    m = M -2

print(n * m)

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

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

x = n - 2
if x < 0:
    x = 0

y = m - 2
if y < 0:
    y = 0

if n == 1 and m == 1:
    print(1)
elif n == 1 and m > 1:
    print(y)
elif n > 1 and m == 1:
    print(x)
else:
    print(x * y)

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

Solution (Python):


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

x = 1 if n == 1 else n - 2
y = 1 if m == 1 else m - 2

print(x * y)

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

Solution (Python):
l = input().split()
N = int(l[0])
M = int(l[1])

if N >= 2:
	N -= 2

if M >= 2:
	M -= 2

print(N * M)

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

Solution (Python):
import math

a=input().rstrip().split(" ")
n=int(a[0])
m=int(a[1])
sum=0
if(n==1 and m==1):
    print(1)
elif(n==2 or m==2):
    print(0)
elif(n==1 or m==1):
    print(n*m-2)
else:
    print((n-2)*(m-2))

Solution (Python):
S = input().split(" ")
A = int(S[0]) * int(S[1]) - int(S[0])*2 - (int(S[1])*2-4)
if (int(S[0]) == 1 or int(S[1]) == 1) and int(S[0]) * int(S[1]) != 1:
    A = int(S[0]) * int(S[1]) - 2
A = max(0,A)
print(A)

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

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

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

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

print(C)

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

Solution (Python):
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 * M - ((N - 2) * 2 + (M - 2) * 2) - 4)

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):
N,M = map(int,input().split())
if N >= 2 and M >= 2:
	print((N - 2) * (M - 2))
elif N >= 2:
	print((N - 2) * M)
elif M >= 2:
	print((M - 2) * N)
else:
	print(N * M)

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

if max(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 or M == 1:
    print(N * M - 2)
elif N == 2 or M == 2:
    print(0)
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):
import numpy as np

n, m = list(map(int, input().split()))
a = 0

if n == 1 or m == 1:
    if n == m:
        a = 1
    else:
        a = n + m - 3
elif n == 2 or m == 2:
    a = 0
else:
    a = (n - 2) * (m - 2)

print(a)

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):
x,y = (int(i) for i in input().split())
if x == 2 or y == 2: answer = 0
elif x == 1 and y == 1: answer = 1
elif x == 1 or y == 1: answer = x+y-3
else: answer = (x-2)*(y-2)
print(answer)

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

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

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

elif N == 2 or M == 2:
    print(0)

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

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

Solution (Python):
data = input()
data = data.split(" ")
n = int(data[0])
m = int(data[1])
if n>1 and m>1: print(n*m-2*(n+m)+4)
elif n==1 and m==1: print(1)
else: print(n*m-2)

Solution (Python):


n,m=map(int,raw_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())

if n > m:
    n, m = m, n

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

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

a = n - 2 if n > 2 else 0
b = m - 2 if m > 2 else 0
counter =  a * b

if counter == 0:
    if n == 1 and m == 1:
        counter = 1
    elif n == 1:
        counter = m - 2
    else:
        counter = n - 2

print(counter)

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

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

Solution (Python):

X,Y = map(int, input().split())

count=0
if X > 2 and Y > 2:
  count = (X-2) * (Y-2)
elif X == 1 and Y > 2:
  count = Y-2
elif Y == 1 and X > 2:
  count = X-2
elif X == 1 and Y == 1:
  count = 1

print( count )

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):
list = input().split(" ")
x = [int(y) for y in list]
if x[0] == 1 and x[1] == 1:
    count =1
elif x[0] == 1 or x[1] == 1:
    count = max(x[0], x[1])-2
else:
    count = (x[0]-2)*(x[1]-2)
print(count)

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

if N == 1 and 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):
N,M=list(map(int,input().split()))

X=0
if N==1:
    if M==1:
        X=1
    if M==2:
        X=0
    if M>=3:
        X=M-2
if N==2:
    X=0
if N>=3:
    if M==1:
        X=N-2
    if M==2:
        X=0
    if M>=3:
        X=(N-2)*(M-2)
        
print(X)