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):
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())
ans = 0

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):
N,M = map(int,input().split())
"""
mat = [[0]*M for _ in range(N)]
dx = [-1,0,1,-1,0,1,-1,0,1]
dy = [1,1,1,0,0,0,-1,-1,-1]
for i in range(N):
    for j in range(M):
        for k in range(9):
            if 0 <= i+dy[k] <= (N-1) and 0 <= j+dx[k] <= (M-1):
                mat[i+dy[k]][j+dx[k]] += 1
print(mat)
"""
if N == M == 1:
    print(1)
elif N == 1 or M == 1:
    print(N*M-2)
else:
    print(N*M-2*(N+M-2))

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

ans = 0
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,input().split())

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

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

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

print(answer)

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

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

Solution (Python):

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

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

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

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


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

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

Solution (Python):

n,m = map(int, input().split())
ans = n*m
n,m = min(n,m), max(n,m)

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

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

Solution (Python):

import sys


def solve(N: int, M: int):
    if N == 1 and M == 1:
        print(1)
        return 

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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

Solution (Python):
a = list(map(int, input().split()))
if a[0]==1 and a[1]==1:
    print(1)
    exit()
if a[0]==1 or a[1]==1:
    print(max(max(a)-2, 0))
    exit()
print((a[0]-2)*(a[1]-2))

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

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

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

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

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

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

Solution (Python):
import sys

n, m = map(int, sys.stdin.readline().split())
if n > m:
    n, m = m, n

def main():
    if n == 1:
        if m == 1:
            return 1
        else:
            return m - 2
    else:
        return (n - 2) * (m - 2)
        
if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):

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


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

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

elif n == 1:
  print(m - 2)

elif n == 2:
  print(0)
elif n >= 3 and m == 1:
  print(n - 2)
elif n >= 3 and m == 2:
  print(0)

Solution (Python):
def flip(x):
	if x:
		return False
	else:
		return True


n, m = [int(el) for el in 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=map(int,input().split())
if	n*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())

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
if N == 2 or M == 2:
    print(0)
elif N == 1 and M == 1:
    print(N * M)
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):
nums=list(map(int, input().split()))
nums.sort()
if nums[0]==1:
  if nums[1]==1:
    print(1)
  else:
    print(nums[1]-2)
elif nums[0]==2:
  print(0)
else:
  print((nums[0]-2)*(nums[1]-2))

Solution (Python):

import sys
input = sys.stdin.readline

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

H, W = MAP()





















if H==1 and W==1:
	print(1)
else:
	cards = H*W
	if min(H,W) >= 2:
		edges = (H+W)*2-4
	else:
		edges = 2

	edges = (H+W)*2-4 if min(H,W) >= 2 else 0 if H==0 and W== 0 else 2 if min(H,W) == 1 else 0
	
	print(cards-edges)

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

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

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

tate = N - 2 if N >= 3 else 0 if N == 2 else 1
yoko = M - 2 if M >= 3 else 0 if M == 2 else 1

print(tate * yoko)

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






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

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

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

Solution (Python):
N,M=map(int,input().split())
print(((abs(max(N,M)-2)),(M-2)*(N-2))[min(N,M)>1])

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

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

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

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

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

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

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

Solution (Python):

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

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

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

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

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

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

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

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

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


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 S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

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

if N >= 3 and M >= 3:
    print(N * M - 2 * (N + M) + 4)

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

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

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

Solution (Python):
from sys import stdin
import numpy as np
import math

n,m = [int(x) for x in stdin.readline().rstrip().split()]

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

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

Solution (Python):
n, m = list(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 = (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 and M >= 2) or (M == 1 and N >= 2):
    print(max(N, M) - 2)
else:
    print((N - 2) * (M - 2))

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

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

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().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 * m - 2 * n - 2 * m + 4)


if __name__ == '__main__':
    solve()

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

Solution (Python):
N, M = [int(x) for x in input().split()]
if N == M == 1:
  print(1)
elif N == 1 or M == 1:
  print(max(0, N - 2) + max(0, M - 2))
else:
  print((N - 2) * (M - 2))

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

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1

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

main()

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

Solution (Python):


import sys










def main():
    n, m = (int(x) for x in sys.stdin.read().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)

if __name__ == "__main__":
    
    main()

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


if __name__ == '__main__':
    main()

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

Solution (Python):

if __name__ == '__main__':

	n,m = list(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 - 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())

zenbu = N*M
naka = max(N-2,0)*max(M-2,0)
kado = [4,2,1][[N,M].count(1)]
hen = N*M-naka-kado

if N==M==1:
    print(1)
elif N==1 or M==1:
    print(hen)
else:
    print(naka)

Solution (Python):
n,m = map(int,input().split())
print([(n-2)*(m-2),max(n,m)-2,1][(n==1 or m==1)+(n==m==1)])

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 = list(map(int,input().split()))

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

Solution (Python):








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

m = M - 2
if m < 0:
    m = 1
n = N - 2
if n < 0:
    n = 1

print(m * n)

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

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

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
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 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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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

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


if __name__ == '__main__':
    main()

Solution (Python):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

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



if __name__ == '__main__':
    main()

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

if n == 1 and m == 1:
    print(1)
    sys.exit()
if n == 1 and m == 2:
    print(0)
    sys.exit()
if n == 2 and m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(m - 2)
    sys.exit()
if m == 1:
    print(n - 2)
    sys.exit()
if n == 2 and m == 2:
    print(0)
    sys.exit()
if n == 2 or m == 2:
    print(0)
    sys.exit()

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

print(center)

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)*min(n,m))
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-2)*(M-2))

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

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


if __name__ == "__main__":
    test()

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

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

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

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

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

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

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

Solution (Python):
n,m=map(int,input().split())
if n==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())
a,b =min(n,m),max(n,m)


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

Solution (Python):
ls=[int(s) for s in input().split()]
ls.sort()
if ls[1]==1:
  print(1)
elif ls[0]==1:
  print(ls[1]-2)
else:
  print((ls[0]-2)*(ls[1]-2))

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

Solution (Python):
import itertools
import sys
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M = inputs()
if N>=2 and M>=2:
    print((N-2)*(M-2))
    exit()
else:
    if N==1 and M==1:
        print(1)
        exit()
    print(max(N-2,M-2))

Solution (Python):
import sys

n, m = [int(_) for _ in input().split()]
ans = 0
if n == 1 and m == 1:
    ans = 1
    print(ans)
    sys.exit()
if 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 or m == 1:
    print(max(n, m)-2)
else:
    print((n-2)*(m-2))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
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:
  n, m = m, n

if m >= 2:
  n9 = (n-2) * (m-2)
  n4 = 4
  n6 = n * m - n9 - n4
  print(n9)
elif m == 1 and n >= 2:
  n2 = 2
  n3 = n * m - 2
  print(n3)
elif m == 1 and n == 1:
  print(1)

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

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