#include <bits/stdc++.h>
using namespace std;
long long N,M,rez,centr,okvir;
int main(){
  cin>>N>>M;
  if(M==1 or N==1){
    rez=M*N;
  }

  else{
    centr=((M-2)*(N-2))/2;
    okvir=2*(M+N)-4;
      rez = centr+okvir;
  }
  cout<<rez<<endl;
  return 0;
}