#pragma GCC optimize("unroll-loops")
#pragma gcc optimize("Ofast")
#pragma GCC optimization("Ofast")
#pragma optimize(Ofast)
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define str string
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define len(x) x.size()

#define print(a)          \
    for (auto &x : a)     \
        cout << x << " "; \
    cout << endl;

#define printmp(a)    \
    for (auto &x : a) \
        cout << x.fs << " " << x.ss << endl;

const int mod = 1e9 + 7;

int ans(int n, int m){
    if(n == 1 and m == 1)
        return 1;
    if(n == m)
        return n * n + ans(n - 1, n) + ans(1, n);
    if(n > m)
        swap(n, m);
    return n * m + ans(n, m - 1) + ans(n, 1);
}

void solve()
{
    int n, m;
    cin >> n >> m;
    cout << ans(n, m);
}

signed main()
{
    fastio int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
        cout << endl;
    }
}