#include "bits/stdc++.h"
using namespace std;
 
int main() {
	long long n, m;
	cin >> n >> m;
	if(n > m) swap(n, m);
	if(n == 1 and m > 2) cout << m - 2 << endl;
	else cout << n * m - 2 * m - 2 * n + 4 << endl;
}