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






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1





N,M = IL()
if N==M==1:
  PE(1)
if N==1:
  PE(M-2)
if M==1:
  PE(N-2)
P((N-2)*(M-2))

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,m=MI()
if n>m:
    n,m=m,n

if n==1:
    if m==1:
        ans=1
    else:
        ans=m-2
else:
    ans=n*m-2*(n+m-2)
print(ans)

Solution (Python):
N,M = (int(x) for x in 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-2)*(M-2))

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

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

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

Solution (Python):
def main():
  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*m-2*(n+m)+4)
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(max(n, m) - 2)
else:
  print((n - 2) * (m - 2))

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))



H,W=map(int,input().split())


if H==1 and W==1:
    ans=1
elif H==1 or W==1:
    ans=max(H,W)-2
else:
    ans=(H-2)*(W-2)
print(ans)

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

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

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

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

Solution (Python):

"""
Created on Thu May 14 00:52:36 2020

@author: shinba
"""

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

ans = 0

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

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

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

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

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

if n == 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):
H,W = map(int, input().split())
if H == W == 1:
    print(1)
    exit()
if H == 1 or W == 1:
    print (max(W,H)-2)
    exit()
print(W*H - (2*H+2*W-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):
def main():
    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))


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

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

    if n == 1 or m == 1:
        ans = max(0, max(n, m) - 2)
        print(ans)
        return
    else:
        x = max(0, n - 2)
        y = max(0, m - 2)
        ans = x * y
        print(ans)
        return


if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(N: int, M: int):
    if N < M:
        N, M = M, N
    if N == 1:
        return 1
    if M == 1:
        return N - 2
    return (N - 2) * (M - 2)



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))  
    print(solve(N, M))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time
from fractions import gcd



def I(): return int(input())


def MI(): return map(int, input().split())


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


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False



def main():
    N, M = MI()

    
    
    
    
    

    
    
    
    
    

    

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

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

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

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

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

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

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

def main():
    N, M = map(int, readline().rstrip().split())
    if N == 1 and M == 1:
        print(1)
        return
    if N == 1 or M == 1:
        print(max(N, M) - 2)
        return
    print((N-2) * (M-2))
    return


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):


import io
import sys

nim, mike = map(int,input().split())
print(abs(nim - 2) * abs(mike - 2))

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

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-2,M-2)
else:
    ans = N * M - ((2 * N + 2 * M) - 4)
print(ans)

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

Solution (Python):
def main():
  N, M = (int(_) for _ in input().split())
  if N > 1 and M > 1:
    N = max(0, N-2)
    M = max(0, M-2)
    print(N * M)
  else:
    if N * M == 1:
      print(1)
    else:
      print(max(max(N, M)-2, 0))
  return

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

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = l()

n.sort()

if n[0] == 1:
    if n[1] == 1:
        print(1)
    else:
        print(n[1]-2)

else:
    print((n[0]-2)*(n[1]-2))

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

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

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

Solution (Python):
import sys

IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n, m = MII()
    if n > 2 and m > 2:
        print((n-2)*(m-2))
    elif n == 1 and m > 2:
        print(m-2)
    elif n > 2 and m == 1:
        print(n-2)
    elif n == 2 or  m == 2:
        print(0)
    else:
        print(1)


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

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

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

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

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


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

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

Solution (Python):






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

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


print(main())

Solution (Python):
n,m = map(int,input().split())
mx = max(n,m)
mn = min(n,m)

if mn == 1:
    if mx == 1:
        print(1)
    else:
        print(mx - 2)
elif mn >= 2:
    print((mx - 2) * (mn - 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 sys

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

def main():
    res = abs(m - 2) if n == 1 else (n - 2) * (m - 2)
    print(res)

if __name__ ==  '__main__':
    main()

Solution (Python):

import sys


def solve(N: int, M: int):
    print(abs(N - 2) * abs(M - 2))


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

Solution (Python):




mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    """
    N <= M
    N = 1かつ、M = 1のとき、1枚だけあるカードは1毎裏返されるので、答えは1でｓ。
    N = 1かつ M ≠ 1のとき、 M 枚のカードのうち両端のカードは2回、それ以外のカードは
    3回裏替えされるので、答えはM-2
    N >= 2のとき、 N <= M より M >= 2で、このとき、
    ・四隅のカードは4回、　
    ・それ以外のカードは週上のカードは6回 
    ・それ以外のカードは9回
    裏返されるので、答えは、(N-2)(M-2)
    """

    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))
if __name__ == '__main__':
  main()

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(10000)
def resolve():
    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))

if '__main__' == __name__:
    resolve()

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

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

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

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 = 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():
    B = input()
    B = B.split()
    B = [int(i) for i in B]
    n = B[0]
    m = B[1]
    if m * n == 0:
        return 0
    if min(n, m) == 1:
        if max(n, m) == 1:
            return 1
        else:
            return max(n, m) - 2
    else:
        nc = n - 2
        mc = m - 2
        return nc * mc
          
print(main())

Solution (Python):
a,b = map(int,input().split())
if a > 2 and b > 2:
  print((a-2)*(b-2))
elif a == 2 or b == 2:
  print(0)
else:
  print(max(max(a,b)-2,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 >= 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):
url = "https://atcoder.jp/contests/abc090/tasks/arc091_a"
import copy
def main():
    tate, yoko = list(map(int, input().split()))
    count = 0
    if tate == 1 and yoko == 1:
        print("1")
        exit()
    elif tate == 1:
        print(yoko - 2)
        exit()
    elif yoko == 1:
        print(tate - 2)
        exit()
    count += (yoko - 2) * (tate - 2)
    print(count)




if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import math
import copy
import time


line1 = str(input()).split(" ")

for index in range(len(line1)):
    line1[index] = int(line1[index])
if (line1[1] > 1 and line1[0] > 1):
    print( line1[0]*line1[1] - (2*line1[1] + 2*(line1[0]-2)))
elif (line1[1] == 1 and line1[0] == 1):
    print(1)
elif (line1[1] == 0 or line1[1] == 0):
    print(0)
else:
    print(line1[0]*line1[1] - 2)

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

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

print(ans)

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

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

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

Solution (Python):


N, M = list(map(int,input().split()))
if N == 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 == 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) * abs(M - 2))

Solution (Python):
N, M = [int(x) for x in input().split()]
def sol(N,M):
  if N==0 or M==0:
      return 0
  elif N==1 or M==1:
    return abs(abs(N-M)-1)
  x = (abs(3-N)+1)*(M-2)
  y = (abs(3-M)+1)*abs((N-2))
  return min(x,y)

print(sol(N,M))

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

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

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

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

    print(ans)