//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

    typedef long long ll;
    typedef long double ld;

#define int long long

void solve() {
    ll n, m;
    cin >> n >> m;

    ll rez = 0;
    ll one_n = 0;
    ll last = n;
    for (int i = n; i >= 1; --i) {
        if (last % i == 0) {
            one_n += n;
            last = i;
        }
    }

    for (int i = m; i >= 2; --i) {
        rez += n * i;
    }
    rez += one_n * m;

    last = m;
    ll one_m = 0;
    for (int i = m; i >= 1; --i) {
        if (last % i == 0) {
            one_m += m;
            last = i;
        }
    }

    ll rez2 = 0;
    for (int i = n; i >= 2; --i) {
        rez2 += m * i;
    }
    rez2 += one_m * n;

    rez = max(rez, rez2);
    cout << rez << endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
    }
}
