#include <bits/stdc++.h>

using namespace std;

int main() {
    long long h, w, a, b, c, d, e;
    cin >> h >> w;
    a = h * w;
    b = min(h, w);
    e = max(h, w);
    d = a / b;
    c = (d * (d + 1)) / 2 * b;
    if (b == 1) {
        c += a - 1;
    }
    else {
        c += 2 * a - b;
        if (b > 2) {
            c += (b * (b + 1) / 2 + b - 1) * e;
            c -= 2 * a;
        }
    }
    cout << c;
}