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

using namespace std;

#define int long long

map <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 cur = 1, add = 5, h = 1;
	while(h <= (int)1e6) {
		mp[h] = cur * h;
		cur += add;
		add += 2;
		h ++;
	}
	queue <pair <int,int>> q;
	q.push({n, m});
	int ans = 0;
	while(!q.empty()) {
		pair <int,int> v = q.front();
		q.pop();
		int mn = min(v.first, v.second), mx = max(v.first, v.second);
		ans += mp[mn];
		if(mn == mx) continue;
		ans += mx * mn;
		q.push({mn, mx - mn});
	}
	cout << ans;
	return 0;
}