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

L=max(n,m)
S=min(n,m)

if L==1 and S==1:
    print(1)
elif S==1:
    print(L-2)
else: print((L-2)*(S-2))

Solution (Python):
n = raw_input()
n= n.split()
N = int(n[0])
M = int(n[1])
if N ==1 and M == 1:
	ANS = 1
if (N == 1 and M  >= 2) or (M == 1 and N >= 2) :
	ANS = N*M - 2
elif N >= 2 and M >= 2:
	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:
    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):
j = list(map(int, input().split()))
counter = 0
j.sort()

if (j[0] >= 3):
  print((j[0] - 2) * (j[1] - 2))
elif (j[0] == 2):
  print(0)
elif (j[0] == 1):
  if j[1] == 1:
    print(1)
  else:
    print(j[1] - 2)

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

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

Solution (Python):
print(abs(eval('~-~-'+input().replace(' ','*~-~-'))))

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

solve()

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

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

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

Solution (Python):
eval('print(abs(('+input().replace(' ','-2)*(')+'-2)))')

Solution (Python):
print(eval('abs(('+input().replace(' ','-2)*(')+'-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((m-2)*(n-2))

Solution (Python):
a,b=map(int,input().split());print(abs((a-2)*(b-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):
a = list(map(int, input().split()))
if a[0] == 1 and a[1] == 1:
    b = 1
elif a[0] == 1:
    b = a[1] - 2
elif a[1] == 1:
    b = a[0] - 2
else:
    b = (a[0] - 2) * (a[1] - 2)
print(b)

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

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

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

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

def retCard(n,m):
    global ans
    
    if n == 1 and m == 1:
        ans = 1
        return 0
    if n == 2 and m == 2:
        ans = 0
        return 0
    if n == 1 or m == 1:
        ans = max(n,m) - 2
        return 0
    
    ans = (n - 2) * (m - 2)
    return 0

retCard(N,M)
print(ans)

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

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

Solution (Python):

"""
C - Flip,Flip, and Flip......
https://beta.atcoder.jp/contests/abc090/tasks/arc091_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, M):
    if N == 1:
        if M == 1:
            return 1
        else:
            return M - 2
    if M == 1:
        return N - 2

    return (M - 2) * (N - 2)



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


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
lis = list(map(int, input().split()))
n = lis[0]
m = lis[1]
count = 0

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

Solution (Python):
def c_flip(N, M):
    if N == 1 and M == 1:
        
        return 1
    elif N == 1 or M == 1:
        
        return max(N, M) - 2
    else:
        
        return (N - 2) * (M - 2)
    return None 

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

Solution (Python):
input_data = input().split()
n = int(input_data[0])
m = int(input_data[1])

if n == 1 or m == 1:
    if 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)

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

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

Solution (Python):
rows, columns = map(int, input().split(' '))

if rows == 1 and columns == 1:
    print(1)
    exit()

if rows == 1:
    print(columns - 2)
    exit()

if columns == 1:
    print(rows - 2)
    exit()

print(rows * columns - 2 * rows - 2 * columns + 4)

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

Solution (Python):

n,m=map(int,input().split())
if n==m==1:
    print(1)
    exit()
ans=0
ans+=max((n-2),0)*max((m-2),0)
if n==1 and n!=m or m==1 and m!=n:
    ans+=max(n,m)-2
print(ans)

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

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

elif N == 2 or M == 2:
    print(0)
    
else:
    print(N*M - ((N-2)*2+(M-2)*2+4))

Solution (Python):
n,m = map(int, raw_input().split(" "))
if n==1==m:
    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):
N,M=input().split()
N,M=[int(N),int(M)]

def countCard(j,i):
	count = 0
	left=0
	right=0
	up =0
	down=0

	if j-1 >= 0:
		left = 1

	if j+1 < M:
		right = 1

	if i-1 >= 0:
		up = 1

	if i+1 < N:
		down = 1

	a= left + right + up + down
	if a == 4:
		return 0	
	elif a == 3:
		return 1	
	elif a == 2:
		if left + right == 0 or up+down==0:
			return 0	
		else:
			return 1	
	elif a == 1:
		return 1	
	elif a == 0:
		return 0

ans = 0

if M >= 3 and N >=3:
	ans = (M-2)*(N-2)
elif M == 1 and N ==1:
	ans = 1
elif N == 1 and M > 2:
	ans = M -2
elif M ==1 and N>2:
	ans = N-2
else:
	status = [[1]*M]*N
	for i in range(N):
		for j in range(M):
			status[i][j] = countCard(j,i)
			ans += status[i][j]
	ans = (M*N) - ans

print(ans)

Solution (Python):


def check_circle(s):
    x = str(s)
    flag = True
    for i in range(int(len(x) / 2)):
         if x[i] != x[-1 * (i + 1)]:
              flag = False
    return flag

def solve(N, M):
    return abs((N - 2) * (M - 2))
    if N == 1:
        return N * M - 2
    if M == 1:
        return N * M - 2
    return N * M - 4
    if N == M and N == 1:
        return 1
    if N == M and N == 0:
        return 0

    if N >= 2:
        tate = 2 * (M - 2)
    elif N == 1:
        tate = M - 2
    if M >= 2:
        yoko = 2 * (N - 2)
    elif M == 1:
        yoko == M - 2
    else:
        yoko = N - 2
    ans = tate + yoko
    return ans

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


if __name__ == '__main__':
    main()

Solution (Python):


n,m = input().split()

N = int(n)
M = int(m)

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

Solution (Python):
l = raw_input().split()
a = int(l[0])
b = int(l[1])
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):


in1 = input().split()

in1 = [int(i) for i in in1]

if(in1[0]==1 and in1[1]==1):
    print("1")
elif(in1[0]==1 or in1[1]==1):
    print((in1[0]-2)*(in1[1]-2)*(-1))
else:
    print((in1[0]-2)*(in1[1]-2))

Solution (Python):





if __name__ == '__main__':
    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):
L,M=map(int,input().split())
count=0
if L==1 and M==1:
    print(1)
elif L==1 or M==1:
    print(L+M-3)
if L==2 or M==2:
    print(0)
if L>=3 and M>=3:
    print((L-2)*(M-2))

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

print(abs((M-2)*(N-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 == 1:
    print(1)
else:
    print(n * 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):
im = []
im = input().split(' ')
N = int(im[0])
M = int(im[1])
if (N == 1 and M == 1) or (N != 1 and M != 1):
    print((N - 2) * (M - 2))
else:
    print(N * M - 2)

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

    f(N, M)


def f(N, M):
    """
    カードAおよび周り8方向を裏返す
    すべてのカードについて行う
    うらの数(1)の枚数

    1 <= N,M <= 10^9
        シミュレート: TLE
    """
    ans = 0
    if N == 1 and M == 1:
        ans = 1
    elif N == 2 or M == 2:
        ans = 0
    elif N >= 3 and M >= 3:
        ans = (N-2) * (M-2)
    else:
        
        ans = max(N, M) - 2

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
a = list(map(int, input().split()))
N = a[0]
M = a[1]
sum = N*M
delt = N*2+(M-2)*2
sum = abs(sum -delt)
print(sum)

Solution (Python):
a,b = map(int,input().split())
def judge(x):
    if x == 1:
      return 1
    elif x == 2 or x == 3:
	    return 0
    elif x > 4:
      return x-2
      
a = judge(a)
b = judge(b)

print(a*b)

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

Solution (Python):
if __name__ == "__main__":
    N, M = list(map(int, (input().split(' '))))
    ura = 0
    if N == 1 and M != 1:
        arr = [0 for i in range(N)]
        ura = M - 2
    elif N != 1 and M == 1:
        arr = [0 for i in range(M)]
        ura = N - 2
    elif N == 1 and M == 1:
        ura = 1
    else:















        ura = N * M - (N * 2 + M * 2 - 4)
    print(ura)

Solution (Python):
A,B=map(int,input().split(' '))
A=1 if A==1 else A-2
B=1 if B==1 else B-2
print(A*B)

Solution (Python):


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

if n == 1:
    if m == 1:
        ans = 1
    else:
        ans = m-2
else:
    if m == 1:
        ans = n-2
    else:
        ans = (n-2)*(m-2)

print(ans)

Solution (Python):
a,b=map(int,input().split())
if a>2 and b>2:
    cnt=a*b-(a*2+b*2-4)
elif (a==1 and b>2) or (a>2 and b==1):
    cnt=a*b-2
elif (a==2 or b==2):
    cnt=0
elif a==1 and b==1:
    cnt=1
print(cnt)

Solution (Python):


def main():
    N,M = list(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*M - (2*(N+M)-4))


if __name__ == '__main__':
    main()

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

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

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

p = n - 2
if p < 0:
    p = 1
q = m - 2
if q < 0:
    q = 1
res = p * q

print(res)

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

Solution (Python):


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


a = n-2 if n>1 else 1
b = m-2 if m>1 else 1

print(a*b)

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

Solution (Python):

import sys

N,M = map(int, input().split(' '))
num = 0
if N == 1:
    if M < 2:
        print(1)
        sys.exit()
    print(str(M-2))
    sys.exit()
elif N == 2:
    print(0)
    sys.exit()
else:
    if M < 2:
        num = N-2
    else:
        num = (M-2)*(N-2) 
    print(num)

Solution (Python):
n,m=[int(i) for i in input().split()]
ans=0

ans=(n-2)*(m-2)

if n==1:
    ans=m-2
if m==1:
    ans=n-2

if n==1 and m==1:
    ans=1
if n==2 and m==1:
    ans=0
if m==2:
    ans=0


print(ans)

Solution (Python):
IN = input().split(" ")
N = int(IN[0])
M = int(IN[1])
if M == 1 and N != 1:
    print(N - 2)
elif N == 1 and M != 1:
    print(M - 2)
else:
    print(M*N-2*N-2*M+4)

Solution (Python):
A,B = map(int,input().split(" "))
ans = 0
if A >=3 and B >= 3:
    ans = A*B-(A*2 + B*2)+4
    print(ans)

if A == 1 and B!=1:
    print(B-2)
elif B == 1 and A != 1:
    print(A-2)
elif A == 1 and B ==1:
    print(1)
elif A == 2 and B >=2:
    print(0)
elif B == 2 and A >=2:
    print(0)

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

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

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

    if min(N, M) == 1:
        i = max(N, M)
        if i == 1:
            back = 1
        elif i == 2:
            back = 0
        else:
            back = i - 2
    elif N == 2 or M == 2:
        back = 0
    else:
        back = N * M - ((N + M) * 2 - 4)
    print(back)

main()

Solution (Python):
if __name__ == '__main__':
    N, M = [int(v) for v in input().split()]

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

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

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

Solution (Python):

n, m = list(map(int, input().split()))
count = 0
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):
a = input()
a = a.split(' ')
A = eval(a[0])
B = eval(a[1])
if A == 2 or B == 2:
    print('0')
else:
    print(abs(A - 2) * abs(B - 2))

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

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

Solution (Python):
def solve():
  c = list(map(int, input().split(' ')))
  if c[0] >= 3 and c[1] >= 3:
    return (c[0] - 2) * (c[1] - 2)
  if c[0] == 1 or c[1] == 1:
    if c[0] == 1 and c[1] == 1:
      return 1
    else:
      return max(max(c) - 2, 0)
  return 0

print(solve())

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

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

ans=0
if n==1:
	if m==1: ans = 1
	if m==2: ans = 0
	if m>=3: ans = m-2

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n,m = na()

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

Solution (Python):
f = lambda :[int(i) for i in input().split()]

N,M = f()

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

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

if N == 1 and M == 1:
	print (1);
elif N == 1 or M == 1:
	print (N+M-3);
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:
    if m==1:
        print(1)
    else:
        print(m-2)
else:
    if 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:
    print(n*m-2*n)
elif m==1:
    print(n*m-2*m)
else:
    print(n*m-(2*n+(m-2)*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 - 2*M - 2*N + 4)

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((N-2)*(M-2))

Solution (Python):


if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    
    if N == 1 and M == 1:
        print("1")
    elif N <= 2 and M <= 2:
        print("0")
    elif N == 1 and M >= 3:
        print(M-2)
    elif N >= 3 and M == 1:
        print(N-2)
    else:
        print((N-2)*(M-2))

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

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

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

Solution (Python):
N, M = [int(i) for i in input().split()]
if N == 1 and M == 1:
	print(1)
elif N == 1 or M == 1:
	print(abs(N-M)-1)
else:
	print(N*M-2*N-2*M+4)

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

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

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

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

print(count)

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

if b >= 2:
    s = b - 2
else:
    s = 1
if a >= 2:
    t = a - 2
else:
    t = 1
q = s * t
print(q)

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

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

if (x[0]==1 and x[1]==1):
    print(1)    
    quit()
elif(x[0]==1):
    print(x[1]-2)    
    quit()
elif(x[1]==1):
    print(x[0]-2)    
    quit()

print((x[0]-2)*(x[1]-2)) 

quit()

Solution (Python):
import collections
from pprint import pprint as pp

ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))

def func(N, M):
    num = 0
    cols = N*M
    if cols == 0:
        return 0
    if cols == 1:
        return 1
    if N == 1:
        return cols - 2
    if N == 2:
        return 0
    return (N-2) * (M-2)
    

l = ria()
N,M = min(l), max(l)
print(func(N,M))

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

if 1 in NM:
    if (max(NM)-2) >= 0:
        print(max(NM)-2)
    else:
        print(1)
elif 2 in NM:
    print(0)
else:
    print(NM[0]*NM[1]-(2*NM[0]+2*NM[1]-4))

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

Solution (Python):
def main():
    N, M = list(map(int, input().split()))
    if (N==1)and(M==1):
        return 1
    elif N == 1:
        return M-2
    elif M == 1:
        return N-2
    else:
        return N*M - (2*(N+M)-4)

if __name__ == '__main__':
    print(main())

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

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

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

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

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

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

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

Solution (Python):
def c_flip(N, M):
    if N == 1 and M == 1:
        return 1
    elif N == 1 or M == 1:
        return max(N, M) - 2
    elif N == 2 or M == 2:
        return 0
    else:
        return N * M - (N * 2 + M * 2 - 4)
    return None

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

Solution (Python):

line = input().split(" ")
n = int(line[0])
m = int(line[1])

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

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

Solution (Python):
import sys

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

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

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

Solution (Python):
n,m = map(int,raw_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
  exit(0)

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

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

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

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

Solution (Python):
nm = input().split()
n = int(nm[0])
m = int(nm[1])
print(abs((n-2)*(m-2)))

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

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

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

if not n == 1:
  n -= 2

if not m == 1:
  m -= 2

print(n * m)

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

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

print(res)

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

if [N, M] == [1, 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:
    if m==1:
        print(1)
        exit()
    print(m-2)
    exit()
if m==1:
    print(n-2)
    exit()
print(n*m-(n*2+m*2-4))

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

Solution (Python):
n, m = map(int, input().strip().split(" "))
if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n - 2, m - 2))
elif n == 2 or m == 2:
    print(0)
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, raw_input().split())
if n + m == 2: print 1
elif n + m == 3: print 0
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 and M==1:
    print(1)
if N==1 and M!=1:
    print(M-2)
if M==1 and N!=1:
    print(N-2)
if N!=1 and M!=1:
    print((M-2)*(N-2))

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

Solution (Python):




def main():
    temp=input()
    temp=list(map(int,list(temp.split(" "))))    
    a=int(temp[0])
    b=int(temp[1])
    c=a*b
    count=c-2*a-2*b+4
    if count<0:
        count*=-1
    print(count)


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


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 * (N + M) + 4)

Solution (Python):

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