#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fin(s) freopen(s, "r", stdin);
#define fout(s) freopen(s, "w", stdout);
#define ui unsigned int
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pk pop_back
#define pf push_front
#define pt pop_front
void solve() {
    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1 << '\n';
        return;
    }
    if (n == 1) {
        cout << (1 + m) * m / 2 + m - 1 << '\n';
        return;
    }
    if (m == 1) {
        cout << (1 + n) * n / 2 + n - 1 << '\n';
        return;
    }
    if (n < m)
        swap(n, m);
    ll res = n * m * 2;
    for (int j = n - 1; j >= 1; --j)
        res += (j + 1) / j * m * j + (j + 1) % j * m;
    cout << res;
}
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    fin("input.txt")
//    fout("output.txt")
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    return 0;
}