#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    long long h, w, h1, w1, sum = 0, fsq;
    cin >> h >> w;
    fsq = h * w;
    sum = fsq;
    while(h > 1 || w > 1){
        h1 = min(h, w);
        w1 = max(h, w) - 1;
        if (h1 != 0 && w1 != 0)
            sum += fsq / (h1 * w1) * (h1 * w1);
        h = min(h1, w1);
        w = max(h1, w1) - 1;
        if (h != 0 && w != 0){
            sum += (fsq / (h * w)) * (h * w);
            if(((h1 * w1) / (h * w)) != (fsq / (h * w)) && h != 1 && w != 1)
                    sum = sum - (h * w);
        }
    }
    cout << sum;
    return 0;
}
