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 in C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Math;
using static Scanner;

class Solver
{
    static void Main(string[] args) {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Solve(new Cin<long>());
        Console.Out.Flush();
    }

    static void Solve(Cin<long> ScanLong) {
        var (N, M) = ScanLong;
        Console.WriteLine(Abs(N * M - 2 * (N + M) + 4));
    }
}

public readonly struct Cin<T>
{
    [MethodImpl(256)]
    public static implicit operator T(in Cin<T> _) => Scan<T>();
    [MethodImpl(256)]
    public T[] Array(int l) {
        var array = new T[l];
        for (int i = 0; i < array.Length; i++) array[i] = Scan<T>();
        return array;
    }
    [MethodImpl(256)]
    public T[,] Array2D(int x, int y) {
        var array = new T[x, y];
        for (int i = 0; i < x; ++i) for (int j = 0; j < x; ++j) array[i, j] = Scan<T>();
        return array;
    }
    [MethodImpl(256)]
    public void Deconstruct(out T a, out T b) => (a, b) = (Scan<T>(), Scan<T>());
    [MethodImpl(256)]
    public void Deconstruct(out T a, out T b, out T c) => (a, b, c) = (Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)]
    public void Deconstruct(out T a, out T b, out T c, out T d) => (a, b, c, d) = (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)]
    public void Deconstruct(out T a, out T b, out T c, out T d, out T e) => (a, b, c, d, e) = (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
    [MethodImpl(256)]
    public void Deconstruct(out T a, out T b, out T c, out T d, out T e, out T f) => (a, b, c, d, e, f) = (Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>(), Scan<T>());
}

public class Scanner
{
    const int BUFFER_SIZE = 1024, CHAR_BEGIN = 33, CHAR_END = 126, CHAR_ZERO = 48, CHAR_NINE = 57;
    static readonly Stream stdin;
    static readonly byte[] buffer;
    static int size, p;
    static bool isEof;
    static Scanner() {
        stdin = Console.OpenStandardInput();
        buffer = new byte[BUFFER_SIZE];
    }
    [MethodImpl(256)]
    private static byte Read() {
        if (isEof) return default;
        if (p < size) return buffer[p++];
        p = 0;
        if ((size = stdin.Read(buffer, 0, BUFFER_SIZE)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    [MethodImpl(256)]
    private static char Next() {
        byte b;
        do b = Read();
        while (!(CHAR_BEGIN <= b && b <= CHAR_END));
        return (char) b;
    }
    [MethodImpl(256)]
    private static string Str() {
        var sb = new StringBuilder();
        for (var c = Next(); CHAR_BEGIN <= c && c <= CHAR_END; c = (char) Read()) {
            sb.Append(c);
        }
        return sb.ToString();
    }
    [MethodImpl(256)]
    private static int Int() {
        int temp = 0;
        for (var c = Next(); CHAR_ZERO <= c && c <= CHAR_NINE; c = (char) Read()) {
            temp = temp * 10 + c - CHAR_ZERO;
        }
        return temp;
    }
    [MethodImpl(256)]
    private static long Long() {
        long temp = 0;
        for (var c = Next(); CHAR_ZERO <= c && c <= CHAR_NINE; c = (char) Read()) {
            temp = temp * 10 + c - CHAR_ZERO;
        }
        return temp;
    }
    [MethodImpl(256)]
    private static double Double() => double.Parse(Str(), CultureInfo.InvariantCulture);
    [MethodImpl(256)]
    public static string ScanStrLine() {
        var sb = new StringBuilder();
        for (var c = Next(); c != '\n' && c != 0; c = (char) Read()) if (c != '\r') sb.Append(c);
        return sb.ToString();
    }
    [MethodImpl(256)]
    public static T Scan<T>() {
        if (typeof(T) == typeof(int)) {
            var i = Int();
            return Unsafe.As<int, T>(ref i);
        }
        if (typeof(T) == typeof(long)) {
            var l = Long();
            return Unsafe.As<long, T>(ref l);
        }
        if (typeof(T) == typeof(string)) {
            var s = Str();
            return Unsafe.As<string, T>(ref s);
        }
        if (typeof(T) == typeof(double)) {
            var d = Double();
            return Unsafe.As<double, T>(ref d);
        }
        return default;
    }
    [MethodImpl(256)]
    public static (T1, T2) Scan<T1, T2>() => (Scan<T1>(), Scan<T2>());
    [MethodImpl(256)]
    public static (T1, T2, T3) Scan<T1, T2, T3>() => (Scan<T1>(), Scan<T2>(), Scan<T3>());
    [MethodImpl(256)]
    public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>());
    [MethodImpl(256)]
    public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Scan<T1>(), Scan<T2>(), Scan<T3>(), Scan<T4>(), Scan<T5>());
}