#include <bits/stdc++.h>

#define mp make_pair

using namespace std;
map<pair<long long, long long>, long long> ma;

long long rec(long long n, long long m) {
    if (n < m)
        swap(n, m);
    if (n == 1 && m == 1) {
        return 1ll;
    }
    else if (ma.count(make_pair(n, m))) {
        return ma[mp(n, m)];
    }
    else if (ma.count(make_pair(m, n))) {
        return ma[mp(m, n)];
    }
    else if (n == m) {
        long long k = n * n + rec(1, n) + rec(n, n - 1);
        ma[mp(n, m)] = k;
        ma[mp(m, n)] = k;
        return k;
    }
    else {
        long long k = n * m + rec(1, m) + rec(n - 1, m);
        ma[mp(n, m)] = k;
        ma[mp(m, n)] = k;
        return k;
    }
}

int main(){
    long long h, m;
    cin >> h >> m;
    if (h < m)
        swap(h, m);
    cout << rec(h, m);    
    
}
