#include <iostream>

using namespace std;

int main() {
    long long N, M;
    cin >> N >> M;

    if(N > 3 | M > 3)
    {
        long long obim = N * 2 + (M - 2) * 2;
        long long unutrasnjost = ((N - 2) * (M - 2)) / 2;

        cout << obim + unutrasnjost;
    }
    else
    {
        if(N == 3 & M == 3)
            cout << "8";
        else
            cout << N * M;
    }
}