#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long

using namespace std;

void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
int pow(int a,int b,int m){int ans=1;while(b){if(b&1){ans=(ans*a)%m;}b>>=1;a=(a*a)%m;}return ans;}
int binpow(int a,int b){int ans=1;while(b){if(b&1){ans=(ans*a);}b>>=1;a=(a*a);}return ans;}

const int N = 2e5 + 100, mod = 1e9 + 7, inf = 1e9;
int c(int n, int i){
	return (n - i + 1) * i;
}
main(){
	iostream::sync_with_stdio(false);	
    cin.tie(nullptr);
    cout.tie(nullptr);
   // memset(dp, -1, sizeof(dp));
	int n, m;
	cin >> n >> m;
	if(n < m)
		swap(n, m);
	int ans = 0;
	for(int i = 0; i < n - m; i++){
		ans += m * (n - i);
	}
	ans += m * (m + 1) * m;
	int l = 0;
	for(int i = 1; i <= m; i++){
		l += i * (m - i + 1);
	}
	cout << ans + l * (n - m) - (m == 1) << endl;
}

