// #ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #endif

#include <bits/stdc++.h>
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define precision       \
    cout.precision(11); \
    cerr.precision(11);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb(x) push_back(x)
#define watch(x) cout << #x << " <-- " << x << '\n';
using namespace std;
class MyExcetion : exception {};

const int N = 1e6 + 5;
const int inf = 1e9 + 3;
const ll mod = 1e9 + 7;

/*
*/

ll dp[N];

void solve()
{
    ll a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);

    dp[1] = 1;

    for (ll i = 2; i <= a; i++)
    {
        dp[i] = dp[i - 1] + 1 + i;
    }

    ll res = 0;
    ll cur = a * b;

    for (ll i = 1; i <= b - a; i++)
    {
        res += dp[a];
        res += cur;
        cur -= a;
    }

    // 4 6
    // 1 2

    for (ll i = a; i >= 2; i--)
    {
        res += pow(i, 2);
        res += dp[i];
        res += i * (i - 1);
        res += dp[i - 1];
    }

    res += 1;

    cout << res;
}

int main()
{
    std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
    speed;
    precision;
    int T = 1;
    // cin >> T;
    srand(time(0));
    for (int i = 0; i < T; i++)
        solve();
// #ifndef ONLINE_JUDGE
//     std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
//     std::cout << "\nTime difference = " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << "[ms]" << std::endl;
// #endif
}
