Problem:
 Score : 300 points    Problem Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.
The front and back sides of these cards can be distinguished, and initially every card faces up.  We will perform the following operation once for each square contains a card:   For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.   It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.
Find the number of cards that face down after all the operations.      Constraints  1 \leq N,M \leq 10^9  All input values are integers.         Input Input is given from Standard Input in the following format:  N  M       Output Print the number of cards that face down after all the operations.        Sample Input 1 2 2      Sample Output 1 0  We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.       Sample Input 2 1 7      Sample Output 2 5  After all the operations, all cards except at both ends face down.       Sample Input 3 314 1592      Sample Output 3 496080

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

Solution (Python):
from sys import stdin

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

print(abs(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().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):
from sys import stdin

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

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

Solution (Python):











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


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


def numflips(N,M):
    if N==0: return 0
    if N==1:
        if M==1: return 1
        return (M-2)
    return (N-2)*(M-2)

ans = numflips(N,M)
print(ans)

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

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

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

ans = 0


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

elif (n == 2 and m >= 3) or (m == 2 and n >= 3):
    ans = 0
    print(ans)

elif (n == 1 and m >= 3) or (m == 1 and n >= 3):
    ans = n * m - 2
    print(ans)

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

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

resolve()

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:
        M -= 2
else:
    N -= 2
    M -= 2

print(N * M)

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

if __name__ == '__main__':
    solve()

Solution (Python):




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

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


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




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

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

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

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

Solution (Python):


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


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

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

Solution (Python):
S = input().split(" ")
N = int(S[0])
M = int(S[1])

def calculate(n,m):

    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)
result = calculate(N,M)
print(result)

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

Solution (Python):
def solve():
    N, M = map(int, input().split())
    
    if N == 1 and M == 1:
        print(1)
        exit()
    
    if M < N:
        N, M = M, N
    if N == 1:
        print(M - 2)
        exit()
    
    print((N - 2) * (M - 2))


if __name__ == '__main__':
    solve()

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((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([(n-2)*(m-2),n*m-2,1][(n<2)+(m<2)])

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

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

print(ans)

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

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

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

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

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

Solution (Python):

def main():
    import sys
    
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    
    from itertools import combinations, permutations
    
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    

    

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



if __name__ == '__main__':
    main()

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


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

print(ans)

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

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

if n==1 or m==1:
    print(max(n,m)-2)
else:
    print(max(0, total -((n+m)*2-4)))

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

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

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

Solution (Python):
def c(n):
    if n == 1:
        return n
    elif n == 2:
        return 0
    else:
        return n-2

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

Solution (Python):

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

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

Solution (Python):
w, h = map(int, input().split())
 
count = 0
 
if w == h == 1:
    count = 1
elif w == 1 or h == 1:
    count = max(w,h)-2
else:
    count = (w - 2) * (h - 2)
    
print(count)

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


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

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

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

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

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

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

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

Solution (Python):
N,M=map(int,input().split())
l=[N,M]
l.sort()
buf=0
f=0
c=0
if l[0]==1:
    if l[1]==1:
        print("1")
    else:
        print(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)
  exit()

if N <= 2 and M <= 2 or N == 2 or M == 2:
  print(0)
  exit()

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

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

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

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

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


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

if n==2 or m==2:
  print(0)
  exit()

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

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

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

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

Solution (Python):
H,W=map(int,input().split())

ans=0       


if H==1 and W==1:
    ans+=1


if W<2 and H>=3:
    ans+=(H-2)
if H<2 and W>=3:
    ans+=(W-2)


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

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

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

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

Solution (Python):
import collections


class Solution:
    def solve(self, N: int, M: int) -> int:

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


if __name__ == '__main__':

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

    
    solution = Solution()
    ans = solution.solve(N, M)

    print(ans)

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:
    n, m = sorted([n, m])
    print(n*m-2)
else:
    print(n*m-2*(n+m)+4)

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

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

Solution (Python):
N_gyou, M_retu = map(int, input().split())

if (N_gyou == 2 or M_retu == 2):
    ans = 0
elif (N_gyou == 1 and M_retu == 1):
    ans = 1
elif (N_gyou == 1):
    ans = M_retu - 2
elif (M_retu == 1):
    ans = N_gyou - 2
else:
    ans = (N_gyou - 2) * (M_retu - 2)

print(ans)

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

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

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

Solution (Python):
H,W = map(int, input().split())
h_ = (1 if H==1 else (0 if H == 2 else H-2))
w_ = (1 if W==1 else (0 if W == 2 else W-2))
ret = h_*w_
print(ret)

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

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

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

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

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

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

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

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

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

if n == 1 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 = [int(n) for n in 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 or M == 2:
  print(0)
else:
  print((N-2)*(M-2))

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

n = 1 if n < 2 else n - 2
m = 1 if m < 2 else m - 2

print(n * m)

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

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

Solution (Python):
N, M = sorted(map(int, input().split()))
print(0 if 2 in [N, M] else abs(M - 2) if N == 1 else (N - 2) * (M - 2))

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

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

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

Solution (Python):


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

Solution (Python):
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

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().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())
answer = 0
if N == 1 and M == 1:
    answer = 1
elif N == 1 and M != 1:
    answer = max(0, M-2)
elif N != 1 and M == 1:
    answer = max(0, N-2)
elif M >= 2 and N >= 2:
    answer = (M-2) * (N-2)

print(answer)

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

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

m = max(a, b)

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

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

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

if a == 1:
    if b == 1:
        print(1)
    else:
        print(b - 2)
elif a == 2:
    print(0)
else:
    print((a - 2) * (b - 2))

Solution (Python):



























N, M = map(int, input().split())
N, M = max(N, M), min(N, M)
if N >= 3 and M >= 3:
    ans = N * M - (2 * N + 2 * M - 4)
    print(ans)
    exit()

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

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

if N == 2:
    print(0)
    exit()

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

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

Solution (Python):
N,M = map(int,input().split())
ans = N*M
if N==1 and M==1:
    print(1)
    exit()
if N < 3 and M < 3:
    print(0)
    exit()

even = 0

odd = 0

if N<=M:
    if N==1:
        s = 2*N
        print(ans-s)
    else:
        s = 2*N+2*(M-2)
        print(ans-s)
else:
    if M==1:
        s = 2*M
        print(ans-s)
    else:
        s = 2*M+2*(N-2)
        print(ans-s)

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

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):
def solve(n, m):
    return abs(n * m - 2 * n - 2 * (m - 2))

_n, _m = map(int, input().split())
print(solve(_n, _m))

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

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

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

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

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

if __name__ == '__main__':
    main()

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

Solution (Python):
n, m = map(int, input().split())
cnt = 0
if n == 1 and m == 1:
  corner = 0
  wall = 0
if n > 1 and m > 1:
  corner = 4
  wall = max(0, n-2) * 2 + max(0, m-2) * 2
if n == 1 and m > 1:
  corner = 2
  wall = 0
if n > 1 and m == 1:
  corner = 2
  wall = 0
print(n * m - corner - wall)

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:
  N -= 2
  
if M >= 2:
  M -= 2

print(N*M)

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

ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m == 2:
        ans = 0
    else:
        ans = m - 2

if n == 2:
    ans = 0

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



print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    if N >= 2 and M >= 2:
        print((N - 2) * (M - 2))
    else:
        if N == 1 == M:
            print(1)
        else:
            print(max(N, M) - 2)


if __name__ == '__main__':
    main()

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

"""

n_count_map = [[0 for _ in range(M)] for _ in range(N)]


def update(x, y):
    
    n_count_map[y][x] += 1
    if y + 1 < N:
        n_count_map[y + 1][x] += 1
    if y - 1 >= 0:
        n_count_map[y - 1][x] += 1
    if x + 1 < M:
        n_count_map[y][x + 1] += 1
    if x - 1 >= 0:
        n_count_map[y][x - 1] += 1
    if y + 1 < N and x + 1 < M:
        n_count_map[y + 1][x + 1] += 1
    if y - 1 >= 0 and x - 1 >= 0:
        n_count_map[y - 1][x - 1] += 1
    if y + 1 < N and x - 1 >= 0:
        n_count_map[y + 1][x - 1] += 1
    if y - 1 >= 0 and x + 1 < M:
        n_count_map[y - 1][x + 1] += 1


for n in range(N):
    for m in range(M):
        update(m, n)

print(n_count_map)
"""

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

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

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


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

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

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