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

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

Solution (Python):



import sys

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
    sys.exit(0)
if n == 1:
    print(m - 2)
    sys.exit(0)
if m == 1:
    print(n - 2)
    sys.exit(0)

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

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

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

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

print(ans)

Solution (Python):
a,b=map(int,input().split())
if min(a,b)>=3:
    print( (a-2)*(b-2))
    exit()
if a>b: a,b=b,a
if a==1 and b>=3:
    print(b-2)
if a==2 and b>=3:
    print(0)


if [a,b]==[1,1]:
    print(1)
if [a,b]==[1,2]:
    print(0)
if [a,b]==[2,2]:
    print(0)

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

if n>=3 and m>=3:
  a=n*m
  b=n*2+m*2-4
  ans=a-b
elif n==1 and m==1:
  ans=1
elif n==1 or m==1:
  a=n*m
  b=2
  ans=a-b
elif n==2 or m==2:
  ans=0
  
print(ans)

Solution (Python):
n,m = map(int,input().split())
if(n==1)&(m==1):
    ans = 1
elif(n==1)|(m==1):
    ans = n+m-3
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((M-2)*(N-2))

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

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

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

Solution (Python):
n,m=map(int,input().split())
if n!=1 and m!=1:
  print(n*m-2*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:
  ans = 1
elif min(n,m)==1:
  ans = (n*m)-2
else:
  ans = n*m-(n+m)*2+4
print(ans)

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	h, w = tin()
	
	if h==1 and w==1:
		return 1
	elif h==1 or w == 1:
		return max(h,w)-2
	else:
		return h*w + 4 - 2*h -2*w
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

if N == 1:
    cn = 1
else:
    cn = N-2
if M == 1:
    cm = 1
else:
    cm = M-2

if N == 1 and M == 1:
    print(1)
else:
    print(cm*cn)

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

Solution (Python):
N,M = map(int,input().split())
if N == 2 or M == 2:
    Ans = 0
elif N == 1 or M == 1:
    if not N == M:
        Ans = max(N,M)-2
    else:
        Ans = 1
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)-(N*2)-(M*2)+4)

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

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

Solution (Python):
H,W=list(map(int,input().split()))
if H==1 and W==1:
   print(1)
   exit()
if H==1 or W==1:
   print(H*W-2)
   exit()
futi=(H+W)*2-4
print(H*W-futi)

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, m = inm()
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 = [int(i) for i in input().split()]
if n >= 3 and m >= 3:
    ans = (n - 2) * (m - 2)
elif 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
elif n == 2 or m == 2:
    ans = 0

print(ans)

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

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

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,m = LI()
    if n > m:
        n,m = m,n
    ans = 0
    if n == 1:
        ans = abs(m-2)
    elif n == 2:
        ans = 0
    else:
        ans = (n-2)*(m-2)

    print(ans)
main()

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

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

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

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

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*m - (n*2+m*2-4))

Solution (Python):
_N, _M = map(int, input().split())
N = max(_N, _M)
M = min(_N, _M)
if N >= 3 or M >= 3:
    long = max(1, N - 2)
    short = abs(M - 2)
    print(long * short)
else:
    if N == 1 and M == 1:
        print(1)
    else:
        print(0)

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

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

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

else:
    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 = [int(x) for x in input().split()]
print(abs(n - 2) * abs(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())

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

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

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

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

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

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

Solution (Python):
n, m = list(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):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()

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

if __name__ == '__main__':
    resolve()

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    two = 2
    three = N * M - two
    print(three)
else:
    four = 4
    six = (N - 2) * 2 + (M - 2) * 2
    nine = N * M - four - six
    print(nine)

Solution (Python):
def resolve():
    N, M = [int(i) for i in input().split()]
    if min(N, M) > 1:
        print((N - 2) * (M - 2))
    else:
        if max(N, M) == 1:
            print(1)
        else:
            print(max(N, M) - 2)


resolve()

Solution (Python):
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Solution (Python):
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n, m = map(int, readline().rstrip().split())
    if n == 1 or m == 1:
        print(abs(abs(n - m) - 1))
        return
    print(abs((m - 2) * (n - 2)))


if __name__ == '__main__':
    main()

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

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

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

if __name__ == "__main__":
    main()

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

if n > m:
    t = n
    n = m
    m = t

w = 0

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

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

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

def solve(n,m):
  if n == 1 and m == 1:
    return 1
  elif n == 1:
    return m - 2
  elif m == 1:
    return n - 2
  else:
    return (n-2)*(m-2)
  
print(solve(N,M))

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

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,m = I2()
    if n == 2 or m == 2:
        print(0)
    else:
        print(max(1, n - 2)*max(1, m - 2))

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

n -= 2
m -= 2

ans = 0

if n == 0 or m == 0:
    ans = 0

elif n == -1 and m == -1:
    ans = 1

elif n == -1 or m == -1:
    ans = max(n, m)

else:
    ans = n * m

print(ans)

Solution (Python):

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

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

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

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

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

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

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

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

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

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

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

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

Solution (Python):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 

 










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

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

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

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

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

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

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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n, m = [int(x) for x in 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))



    

t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

Solution (Python):
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 = 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 = map(int, input().split())
if n == m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print(n * m - (n * 2 + (m - 2) * 2))

Solution (Python):




n, m = map(int, input().split())
print(abs(n * m - (n * 2 + (m - 2) * 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 -2)*(M -2)*(-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 * 2 + M * 2 - 4))

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

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

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
if n==1:
	if m==1:
		print(1)
		exit()
	print(m-2)
	exit()
if m==1:
	print(n-2)
	exit()

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

Solution (Python):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()

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

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

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

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

print(ans)

Solution (Python):
n, m = [int(i) for i in input().split()]
print(abs((n - 2) * (m - 2)))

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b = inpl()
if a == 2 or b == 2:
    print(0)
elif 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):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, m = LI()
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((n-2)*(m-2))

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

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

    if N==1 and M==1:
        print(1)
        return
    if N==1 or M==1:
        print(max(N-2,M-2))
        return 
    
    ans=0

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

    print(ans)



if __name__ == "__main__":
    main()

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):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,m = iim()

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

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

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

if min(n,m)==1:
  ans=max(n,m)-2
  print(ans)
  exit()
  
print((n-2)*(m-2))

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

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

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

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

Solution (Python):
import sys









input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    n,m = getList()
    if n == 1 and m == 1:
        print(1)
        return
    if n == 1:
        print(m - 2)
        return
    if m == 1:
        print(n - 2)
        return

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

    return


def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    
    solve()

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

Solution (Python):
lst=map(int,input().split())
lst=sorted(lst)
m=lst[0]
n=lst[1]

if m!=1:
    ans=m*n-2*(m+n)+4
    print(ans)
else:
    if n==1:
        print(1)
    else:
        print(n-2)

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

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

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

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

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(max(n,m)-2)

Solution (Python):


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

ans = 0 
if n>=3 and m>=3:
    ans = n*m - ((n+m)*2-4)

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

print(ans)