#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define ll long long
using namespace std;
int main()
{
    ll h, w;
    cin >> h >> w;
    unsigned ll sum = (abs(h - w) + 1) * (min(h, w) * min(h, w) + h * w) / 2;
    sum += (abs(h - w) * (1 + min(h, w)) * min(h, w) / 2);
    sum += (min(h, w) - 1) * abs(h - w);
    for (unsigned ll k = 2; k <= min(h, w); k++) {
        sum += ((k - 1) * k + (k - 1) * (k - 1));
        sum += k * (1 + k) / 2;
        sum += (k - 1);
        sum += (k - 1) * k / 2;
        sum += (k - 2);
    }
    cout << sum;
    return 0;
}