#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, m;
	cin>>n>>m;
	long long d[1000005];
	long long ans = 1;
	d[1] = 1;
	for(long long i=2;i<=1000000;i++){
		d[i] = d[i - 1] + (long long)1 + i;
	}
	long long mi = min(n,m);
	long long curx = 1, cury = 1;
	for(long long i=1;i<=2*mi;i++){
	    if(curx == mi && cury == mi){
	        break;
	    }
	    if(curx > cury){
	        cury++;
	        ans += curx * cury;
	        ans += d[curx];
	    }
	    else{
	        curx++;
	        ans += curx * cury;
	        ans += d[cury];
	    }
	}
	for(long long i=mi + 1;i<=max(n, m);i++){
	    curx++;
	    ans += curx * cury;
	    ans += d[cury];
	}
	cout<<ans<<endl;
}
