#include <iostream>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int M;
    int N;
    int rez;


    cin >> N;
    cin >> M;


    if(M<3 || N<3) cout << M*N;
    else cout << 2*N + 2*M + (N-2)*(M-2)/2-4;

    return 0;



}