// Bismi ALlah
#include "bits/stdc++.h"

using namespace std;

#define int long long

map <pair <int,int>,int> mp;

void f(int n, int m) {
	if(mp.count({n, m})) return;
	if(n == 1 && m == 1) {
		mp[{n, m}] = 1;
		return;
	}
	if(n > m) {
		f(n-1, m);
		f(1, m);
		mp[{n, m}] = mp[{n-1, m}] + mp[{1, m}] + n * m;
	}else {
		f(n, m-1);
		f(n, 1);
		mp[{n, m}] = mp[{n, m-1}] + mp[{n, 1}] + n * m;
	}
}

signed main () {
	int n, m;
	cin >> n >> m;
	int i = 1, j = 1, ans = 1;
	mp[{1, 1}] = 1;
	for(int i= 2; i <= (int)(1e6); i ++) {
		mp[{i, 1}] = mp[{i-1, 1}] + 1 + i;
		 mp[{1, i}] = mp[{i, 1}];
	}
	while(1) {
		if(i ==n && j == m) break;
		if((i < j && i < n) || j == m) {
			i ++;
			ans += i * j + mp[{j, 1}]; 
		}else {
			j ++;
			ans += i * j + mp[{1, i}];
		}
	}
	cout << ans;
	return 0;
}