#include <iostream>
#include <math.h>
using namespace std;

long long n, m, a, b;

int main() {
    cin>>n>>m;
    if(n < m) {
        a = n;
        b = m;
    }
    else {
        a = m;
        b = n;
    }
    if(a == 1) {
        cout<<abs(b-2);
    }
    else {
        cout<<(a-2)*(b-2);
    }
}