#include <bits/stdc++.h>

using namespace std;

int main () {
    long long n, m;
    cin >> n >> m;
    cout << max(m, n) * ((min(m, n) * (min(m, n) + 1) / 2) + (min(m, n) - 1)) + min(m, n) * ((max(m, n) * (max(m, n) + 1) / 2) - 1);
}
