#include <bits/stdc++.h>

#define fi first
#define se second

#define pw(x) (1LL << x)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz(x) (int)(x).size()

using namespace std;

template < typename T >
bool umn (T& a, T  b) {return a > b ? a = b, 1 : 0;}
template < typename T >
bool umx (T& a, T  b) {return a < b ? a = b, 1 : 0;}

using ll = long long;
using ld = long double;

const int N = 1e6 + 5;
ll res = 0;
void solve(ll n, ll m) {
    while (n || m) {
        res += n * m;
        if (n > m) {
            if (n != 1) res += m * (m + 1) / 2 + (m - 1);
            n--;
        }
        else {
            if (m != 1) res += n * (n + 1) / 2 + (n - 1);
            m--;
        }
    }
}

int main() {
#ifdef localy
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
#endif // localy
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, m;
    cin >> n >> m;
    solve(n, m);
    cout << res << endl;
    return 0;
}
