#include <bits/stdc++.h>
 
using namespace std;
 
#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;
 
const int N = 1e6 + 5;
const int inf = 1e9+123;
const ll INF = 1e15 + 5;
const int mod = 1e9 + 7;
const int P = 31;

ll h, ans, w, f[N], dp[N];

void solve(){
    cin >> h >> w;
    ans += h * w;
    for(int i = max(h, w) - 1; i >= min(h, w); i--){
        ans += i * 1LL *  min(h, w);
        ans += f[min(h, w)];
    }   
    ans -= min(h, w) * min(h, w);
    // cout << ans << nl;
    ans += dp[min(h, w)];
    cout << ans << nl;
}
 
signed main() {
    speed;
    int T = 1;
    dp[1] = 1LL;
    for(int i = 1; i <= 1e6; i++)
        f[i] = i + i * (i + 1) / 2 - 1;
    for(int i = 2; i <= 1e6; i++){
        dp[i] = dp[i - 1] + i * i + f[i] + f[i - 1] + (i - 1) * i;
    }
    // cin >> T;
    while(T--)
        solve();
}