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