#include <iostream>

using namespace std;

int main()
{
    long long int N,M;
    cin >> N >> M;
    if(N>=2&&M>=2)
        cout << (N-2)*(M-2)/2 + (2*N + 2*(M-2));
    else if( M > N)
        cout << M;
    else
        cout << N;
    return 0;
}