#include <iostream>

using namespace std;

int main()
{
    long long int n, m;
    cin>>n>>m;
    if(n>2 && m>2)
    {
        long long int orok;
        orok=2*n+2*m-4;
        n-=2;
        m-=2;
        orok+=(n*m)/2;
        cout<<orok;
    }
    else if (n==1)
        cout<<m;
    else if (m==1)
        cout<<n;
    else
        cout<<n*m;

    return 0;
}