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

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

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

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N, M = (int(_) for _ in input().split())
    if N==1 and M==1:
        print(1)
        return
    if N==1 or M==1:
        print(N*M - 2)
        return 
    print((N-2)*(M-2))
    
if __name__ == '__main__':
    main()

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


from math import *
from itertools import *
from collections import *
from bisect import *


if __name__ == '__main__':
    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:
        center = n*m - 2*n - 2*m + 4
        print(center)

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

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

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

Solution (Python):
n, m = list(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((M-2)*(N-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((N-2)*(M-2))

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

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

Solution (Python):

import sys


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

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

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

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

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

str = input().split()
N = int(str[0])
M = int(str[1])

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

Solution (Python):

def solve(N, M):
    
    

    
    
    
    
    
    
    
    def cut(n):
        if n == 1:
            return 1
        elif n == 2:
            return 0
        return n - 2

    return cut(N) * cut(M)

N, M = [int(x) for x in input().split()]
print(solve(N, M))

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  return abs((m-2)*(n-2))

print(main())

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


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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, M: int):
    if N > M:
        N, M = M, N
    ret = 0
    if N == 1:
        if M == 1:
            ret = 1
        else:
            ret = M - 2
    else:
        ret = (N - 2) * (M - 2)
    print(ret)
    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())
print(abs((N - 2) * (M - 2)))

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

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

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

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

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

ans = max(N-2, 0) * max(M-2, 0)

if 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-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:
    print(m-2)

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

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

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

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    n, m = intin()

    if n == 1 and m == 1:
        print(1)
        return
    if n == 1 or m == 1:
        print(max([n - 2, m - 2, 0]))
        return
    if n == 2 or m == 2:
        print(0)
        return

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

Solution (Python):


def main():
    high, width = map(int, input().split())
    min_data = min(high, width)
    max_data = max(high, width)

    if min_data == 1:
        if max_data == 1:
            print(1)
        elif max_data == 2:
            print(0)
        else:
            print(max_data - 2)
    elif min_data == 2:
        print(0)
    else:
        print((high - 2) * (width - 2))



if __name__ == '__main__':
    main()

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

ans = 0
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())
ans = 0
if N > 1 and M > 1:
    ans = (N-2) * (M-2)

elif N==1 and M==1:
    ans = 1
else:
    ans = max(N, M) - 2
print(ans)

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(max(0,n-2,m-2))
else:
    print(max(0,(n-2)*(m-2)))

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

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

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

Solution (Python):


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


def submit():
    
    
    

    
    

    n, m = read_input()
    short_side = min(n, m)
    long_side = max(n, m)

    if short_side == 1:
        if long_side == 1:
            print(1)
        else:
            print(long_side - 2)
    else:
        
        corners = 4
        sides = 2 * (short_side - 2) + 2 * (long_side - 2)
        insides = n * m - corners - sides

        print(insides)



if __name__ == '__main__':
    submit()

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

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


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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

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

def calc(n, m):
    if n < 1 or m < 1:
        return 0
    elif n == 1 and m != 1:
        return m-2
    elif n != 1 and m == 1:
        return n-2
    else:
        return n * m -(2 * (m + n - 2))
print(calc(N,M))

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

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

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

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

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

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

"""
1

44
44

464
696
464

1
2
1

121
"""

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

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

Solution (Python):

import sys


def solve(N: int, M: int):
    print(abs(N-2)*abs(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())





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

print(ans)

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

x=min(m,n)
y=max(m,n)

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

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

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

print(ans)

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

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

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

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

if N > 1 and M > 1:
    print(N*M-(2*(N+M)-4))
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())

back = (N*M)-2*N-2*M+4
if back< 0:
    back*=-1
print(back)

Solution (Python):
a, b = [int(item) for item in input().split()]

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

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

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

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

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

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, M = LI()

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

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

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

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    print(solve(n, m))

def solve(n, m):
    if n > m:
        n, m = m, n
    
    if n * m == 1:
        return 1
    
    if n == 1:
        return n * m - 2
    
    return n * m - (n - 1) * 2 - (m - 1) * 2

main()

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

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

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

Solution (Python):
def solve(string):
    n, m = map(int, string.split())
    if n == 1 and m == 1:
        return "1"
    elif n == 1 or m == 1:
        return str(max(n - 2, m - 2))
    elif n == 2 or m == 2:
        return "0"
    else:
        return str((n - 2) * (m - 2))


if __name__ == '__main__':
    print(solve(input()))

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

n_ = n - 2
if n_ < 0:
    n_ = 1

m_ = m - 2
if m_ < 0:
    m_ = 1

print(n_ * m_)

Solution (Python):



import sys


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

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

count = 0

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

print(count)

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

if N[1] == 1:
    print(1)
elif N[0] == 1:
    print(N[1] - 2)
else:
    print((N[0] - 2) * (N[1] - 2))

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

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)
else:
    print(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):

import numpy as np

def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m)]*n 
def getIntLines(n): return [int(input()) for i in range(n)]
def getIntMat(n, m):  
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat
class Debug():
    def __init__(self):
        self.debug = True

    def off(self):
        self.debug = False

    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, M = getIntList()
    d.dmp((N, M))
    n = abs(N-2)
    m = abs(M-2)
    d.dmp((n,m),'n,m')
    return n*m


ans = prob()
if ans is None:
    pass
elif type(ans) == list and ans[0] == 'col':
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

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

    if 1 < N:
        N -= 2

    if 1 < M:
        M -= 2

    print(N * M)

    return


main()

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


def main():
    if N - 2 < 0 or M - 2 < 0:
        print(max(1, N - 2) * max(1, M - 2))
    else:
        print((N - 2) * (M - 2))

    return


main()

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

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

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

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

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

    N, M = min(N, M), max(N, M)

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


if __name__ == '__main__':
    main()

Solution (Python):
def flip_flip_and_flip(N: int, M: int) -> int:
    if N == 1 and M == 1:
        return 1
    if N == 1:
        return M - 2
    if M == 1:
        return N - 2
    return (N-2)*(M-2)


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

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

def f():
    if n == 1 and m == 1:
        return 1
    if n == 1 or m == 1:
        return max(n,m)-2
    return n*m - 2*n - 2*m + 4

print(f())

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

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

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