#include <bits/stdc++.h>

using namespace std;

int main()
{
    unsigned long long h, w;
    cin >> h >> w;
    unsigned long long sum = 0;
    sum += h * w;
    unsigned long long s = h * w;
    if (h == 1 || w == 1) {
        unsigned long long a = max (h, w);
        unsigned long long c = 0;
        while (a > 1) {
            c += a;
            a--;
        }
        sum += c;
        cout << sum;
        return 0;
    }
        unsigned long long cub = min (h, w) * min (h, w);
        if (cub != h * w && h > 1 && w > 1) {
            sum += cub * sum / cub;
        unsigned long long a = sqrt (cub);
        unsigned long long b = sqrt (cub);
        unsigned long long c = a;
        while (a > 1) {
            c += a;
            a--;
        }
        sum += c * b * (h * w / cub);
        }
        s -= cub * (h * w / cub);
        unsigned long long s1 = min (h, w);
        unsigned long long s2 = max (h, w) % int(sqrt (cub));
        if (s2 == 0)
            s2 = max (h, w);
        unsigned long long c2 = s2;
        while (s2 > 1) {
            c2 += s2;
            s2--;
        }
        sum += c2 * s1;
    cout << sum;
    return 0;
}
