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

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

Solution (Python):


import itertools
import collections
import bisect

def main():
    N, M = map(int, input().split())
    if N > 1 and M > 1:
        print((N-2)*(M-2))
    else:
        if N == 1 and M == 1:
            print(1)
        else:
            print(max(N, M) - 2)


if __name__ == '__main__':
    main()

Solution (Python):
a = list(map(int,input().split()))
N = a[0]
M = a[1]
if N == 1 and M == 1:
    print("1")
elif N == 1 and M >= 2:
    print(str(M-2))
elif N >= 2 and M == 1:
    print(str(N-2))
else:
    print(str((N-2)*(M-2)))

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


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    if N == 2 or M == 2:
        print(0)
    else:
        print(max(1, N-2) * max(1, M-2))


if __name__ == '__main__':
    main()

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

Solution (Python):

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

ans = 0

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

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

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

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


main()

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

Solution (Python):

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

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

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,M=rl()

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

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

Solution (Python):

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

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

Solution (Python):

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

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

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

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

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

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

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

Solution (Python):
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

numbers = input_numbers()

numbers.sort()
if(numbers[0] == 1):
    if(numbers[1] == 1):
        print(1)
    else:
        print(numbers[1] - 2)

else:
    ans = numbers[0] * numbers[1] - (numbers[0] + numbers[1] - 2) * 2

    print(ans)

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

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

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

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

print(res)

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

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

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

Solution (Python):
a, b = [int(x) for x in input().split(" ")]
print(abs((a-2)*(b-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:
    if n == 1:
        print(m-2)
    else:
        print(n-2)
else:
    print(n*m-2*n-2*m+4)

Solution (Python):
def solve(N, M):
    if N > 2 and M > 2:
        return (N - 2) * (M - 2)
    if N == 2 or M == 2:
        return 0
    if N == 1 and M == 1:
        return 1
    return max(max(N, M) - 2, 0)


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    print(solve(N, M))

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

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

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

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

print(ans)

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

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

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

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

if N<M:
    N,M = M,N

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

print(ans)

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

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

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

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

Solution (Python):


def main():
    s = input().split()
    N, M = int(s[0]), int(s[1])

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

    print(t)


if __name__ == '__main__':
    main()

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

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

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

else:
    print(N-2)

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

Solution (Python):
N, M = map(int, input().split())
n_row = N - 2 if N != 1 else 1
n_col = M - 2 if M != 1 else 1

print(n_row * n_col)

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

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

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

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, 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().strip().split())

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

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

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

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

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

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


abc090_c()

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

    if (N > 2) :
        rows = N-2
    elif (N == 1) :
        rows = 1
    else :
        print("0")
        return
    
    if (M > 2) :
        cols = M-2
    elif (M == 1):
        cols = 1
    else :
        print("0")
        return

    print(rows * cols)

main()

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

Solution (Python):
a,b = map(int,input().split(" "))
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 * b - ((a + b) * 2 - 4))

Solution (Python):
li = list(map(int,input().split()))
li.sort()
N = li[0]
M = li[1]

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

if n == 1 and k == 1:
    print(1)
elif n == 1 or k == 1:
    print(n*k-2)
else:
    print(n*k-n*2-k*2+4)

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

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

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

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

Solution (Python):
N, M = sorted([int(_) for _ in 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())

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

print(ans)

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

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

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

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

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

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

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

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

Solution (Python):

iN,iM = map(int,input().split())

if 2 < iN and 2 < iM:
    print((iN-2)*(iM-2))
elif iN == 2 or iM == 2:
    print(0)
else:
    if iN > 1:
        print(iN-2)
    elif iM > 1:
        print(iM-2)
    else:
        print(1)

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

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

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

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

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


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

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

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

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

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

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

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

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

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

Solution (Python):

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

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

if n > m:
    k = n
    n = m
    m = k

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

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

elif n == 2:
    print(0)

Solution (Python):


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

men = N*M

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

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( ))
ans = abs((N-2)*(M-2))
print(ans)

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

Solution (Python):
s=input().split()
l=[int(i) for i in s]
l.sort()
if l[0]==1:
  print(abs(l[1]-2))
else:
  print((l[0]-2)*(l[1]-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(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==1 and M==1:
		print(1)
	elif N==1:
		print(M-2)
	else:
		print(N-2)
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)
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:
    if m > 1:
        print((n - 2) * (m - 2))
    else:
        print(n - 2)
else:
    if m > 1:
        print(m - 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)
else:
    print((n-2)*(m-2))

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

Solution (Python):
n, m = [int(v) for v in 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>2:
    n-=2
if m>2:
    m-=2
if n==2 or m==2:
    print(0)
else:
    print(n*m)

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

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

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

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

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

Solution (Python):
N,M = [int(x) for x 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)
elif n==2 or m==2:
    print(0)
elif n==1 or m==1:
    print(n*m-2)
else:
    print((n-2)*(m-2))

Solution (Python):
import sys

A = list(map(int, input().split()))

N = min(A)
M = max(A)

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

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

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

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

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

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

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

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

print(ans)

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

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

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

N,M = inpl()

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

Solution (Python):


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

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

print(reverse)

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


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


if __name__ == '__main__':
    main()

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

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

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

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

ans = -1
if ary[0] == 1:
    ans = 1 if ary[1] == 1 else (ary[1] - 2)
elif ary[0] == 2:
    ans = 0
else:
    ans = (ary[0] - 2) * (ary[1] - 2)
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:
    n -= 2
if m != 1:
    m -= 2
print(n*m)

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

Solution (Python):

"""
Created on Wed Aug  8 21:52:29 2018

@author: Yuki
"""

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

"""
Created on Wed Aug  8 21:52:29 2018

@author: Yuki
"""

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):
data = [int(n) for n in input().split()]

if(data[0] == 1 and data[1] == 1):
    print(1)
elif(min(data)==1):
    print(max(data)-2)
else:
    print((data[0]-2)*(data[1]-2))

Solution (Python):
import numpy as np

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

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

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

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

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

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

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):
l=list(map(int,input().split()))
N=min(l)
M=max(l)
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())
print(abs((N-2)*(M-2)))

Solution (Python):
a, b = map(int,input().split())
c = [a,b]
c.sort()
if c[0] == 1:
    if c[1]==1:
        print(1)
    else:
        print(c[1]-2)
else:
    print((c[0]-2) * (c[1]-2))

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