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

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, M] = string_to_int(inputs[0])
    if N == 1 and M == 1:
        return 1
    if N == 1 or M == 1:
        return (N * M) - 2
    
    
    if N == 2 or M == 2:
        return 0

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


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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

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

Solution (Python):
h,w=map(int,input().split())

if h>=3 and w>=3:
    print((h-2)*(w-2))
elif w==2 or h==2:
    print(0)
elif w==1 and h>=3:
    print(h-2)
elif h==1 and w>=3:
    print(w-2)
else:
    print(1)

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

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

print(res)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    print(abs(n-2)*abs(m-2))
resolve()

Solution (Python):
import sys

N, M = map(int, input().split())
if N < 2 and M < 2:
    print(1)
    sys.exit()

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

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

Solution (Python):

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

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

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
"""

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

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

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

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

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

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

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

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

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

def main():
    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 and M>=2:
        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((n-2)*(m-2))

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


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

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

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

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

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

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

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

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

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

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

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

def f(x):
    if x == 1:
        return 1
    else:
        return x - 2

ans = f(n) * f(m)
print(ans)

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

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

if N > M:
	N,M = M,N

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

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

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

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((n-2)*(m-2) if n!=1 and m!=1 else n+m-3 if n!=1 or m!=1 else 1)

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):
a, b = map(int, input().split())
print(abs((a-2)*(b-2)))

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

if __name__ == "__main__":
    main()

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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

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

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

Solution (Python):



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

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

print(c)

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

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



N,M = II()

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

import sys


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

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

Solution (Python):
(rows, cols) = (int(tok) for tok in input().split())
res = 1

if rows > 1 and cols > 1:
  res = (rows - 2) * (cols - 2)
elif rows > 1 or cols > 1:
  res = max(rows, cols) - 2

print(res)

Solution (Python):
import sys
from statistics import *
from collections import *
from operator import itemgetter
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:
    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:
  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())
if n>=3 and m>=3:
    print((n-2)*(m-2))
elif n==2 or m==2:
    print(0)
elif n==1:
    if m==1:
        print(1)
    else:
        print(m-2)
elif m==1:
    print(n-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(n-2)
elif m > 1 and n == 1:
    print(m-2)
else:
    print(1)

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

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

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

print(ans)

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


if __name__ == "__main__":
    resolve()

Solution (Python):
n, m = list(map(int, input().split()))
if n == 2 or m == 2:
    print(0)
elif n == 1 or m == 1:
    print(max(1,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 = [int(_) for _ in input().split()]


def calc(N, M):
    ans = 0

    def hashicco(n, m):
        tmp = 1
        if n > 1:
            tmp += 1
        if m > 1:
            tmp += 1
            if n > 1:
                tmp += 1
        res = tmp % 2
        if n > 1:
            res *= 2
        if n > 1:
            res *= 2
        return res

    

    v = 0
    if M > 2 and N == 1:
        v += M - 2
    h = 0
    if N > 2 and M == 1:
        h += N - 2

    return hashicco(N,M)+v+h


res = calc(_N, _M)

if _N >= 3 and _M >= 3:
    res += (_N - 2) * (_M - 2)
print(res)

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

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    if N >=2 and M >=2:
        return (N-2)*(M-2)
    elif [N, M] == [1, 1]:
        return 1
    elif N == 1:
        return M-2
    elif M == 1:
        return N-2

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

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 or M==1) and not (N==1 and M==1) :
    print(N*M-2)
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(max(m-2, 0))
elif m == 1:
    print(max(n-2, 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)
        exit(0)
    else:
        mx = max([n, m])
        print(mx - 2)
        exit(0)
val = (n - 2) * (m-2)
print(val)

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

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

print(ans)

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

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

print(ans)

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

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

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

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

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

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
print(abs(N-2)*abs(M-2))

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

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

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

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

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

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

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

Solution (Python):
h,q=map(int,input().split())

if h==2 or q==2:print(0)
elif h==1 or q==1:
    if h!=1:print((h-2)*1)
    elif q!=1:print((q-2)*1)
    else:print(1)
else:
    print((h-2)*(q-2))

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

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

main()

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

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

print(ans)

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

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



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

Solution (Python):


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,m = list(sorted(getints()))

if n == 1:
    if m != 1:
        res = m - 2
    else:
        res = 1
elif n == 2:
    res = 0
else:
    res = n * m - 2 * n - 2 * m + 4

print(res)

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

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

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

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

Solution (Python):
n,m = map(int,input().split())
if n > m:
    c = m
    m = n
    n = c
if n==1:
    print(abs(m-2))
elif n==2:
    print(0)
else:
    print(n*m - 2*(n+m) + 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());o=n-2;p=m-2;print((m<2)*o+(n<2)*p+3*(m<2>n)+o*p*(m>2<n))

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

Solution (Python):

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

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

Solution (Python):
N,M = [int(zz) for zz in input().split()]
print(abs((N-2)*(M-2)))

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

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

print(ans)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = SR(3)
    for i in range(3):
        print(s[i][i], end="")
    print()
    return


def B():
    a, b = LI()
    ans = 0
    for i in range(a, b + 1):
        x = str(i)
        for k in range(len(x)//2):
            if x[k] != x[-k - 1]:
                break
        else:
            ans += 1
    print(ans)
    return


def C():
    n, m = LI()
    if n == m == 1:
        print(1)
        return
    if n == 1 or m == 1:
        print(max(n - 2, m - 2))
        return
    if n == 2 or m == 2:
        print(0)
        return
    print(n * m - n * 2 - (m - 2) * 2)
    return


def D():
    return


if __name__ == '__main__':
    C()

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

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

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

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

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().rstrip().split(' '))

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

Solution (Python):










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

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

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

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

print(ans)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math





 
def main():
    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()
        
    if N == 2 and M == 2:
        print(0)
        sys.exit()
    
    if N == 2 or M == 2:
        print(0)
        sys.exit()
        
    total = N*M
    total = total - (2*N)
    total = total - (2*M)
    total += 4
    
    print(total)
	
if __name__ == "__main__":
	main()

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

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

Solution (Python):
def solve(N, M):
    if N == 1 and M == 1:
        return 1

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

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


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

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

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

if n>m:
	w=n
	n=m
	m=w

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

Solution (Python):
import sys
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()
if N >= 2 and M >= 2:
    print((N - 2) * (M - 2))
    sys.exit()

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

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

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)
else:
    if M==1:
        print(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 == 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 = 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):

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


if __name__ == "__main__":
    main()

Solution (Python):

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
N, M = [int(nm) for nm in 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):
N,M=sorted(map(int,input().split()))

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

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

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

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

Solution (Python):


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

def F(N,M):
  if N > M:
    N,M = M,N
  
  if N == 1:
    if M == 1:
      return 1
    else:
      
      return M-2
  
  
  return (N-2)*(M-2)

answer = F(N,M)
print(answer)

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