#include<bits/stdc++.h>
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    long n, m;
    cin>>n>>m;
    
	if(n == 2 or m == 2){
    	cout<<2 * (n + m - 2);
	}
	else cout<<2 * (n + m - 2) + (m - 2)*(n - 2)/2;
	
	return 0;
}