#include <bits/stdc++.h>
using namespace std;
int main(){
    long long h, m;
    cin >> h >> m;
    long long k = h;
    if(m < h){
        h = m;
        m = k;
    }
    if(h == 1){
    	cout << m * 2 + (m - 1) * m / 2 - 1;
    	return 0;
	}
    long long summ = 0;
    summ = 3 * h * m;
    for(int i = m - 1; i > 1; i--){
        summ += i * h;
    }
    cout << summ;
}
