import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long n, long m) {
    if (n > m) return calc(m, n);

    if (n == 1) {
        if (m == 1) return 1;
        return m - 2;
    }

    if (n == 2) return 0;

    return (n - 2) * (m - 2);
}

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    auto ans = calc(n, m);
    writeln(ans);
}