//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define forik(x) ll i = 1; i <= x; i++
 
const int mod = 1e9 + 7;
 
using namespace std;
 
ll t, n, m, a, b, c, d, e, dp[1000001];
string s;
map <ll, ll> mp;
vector <ll> g;
 
signed main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    if (n < m){
    	swap (n, m);
	}
    if (n == 1 || m == 1){
        dp[1] = 1;
        a = 3;
        for (int i = 2; i <= max (n, m); ++i){
            dp[i] = dp[i - 1] + a;
            a++;
        } 
        cout << dp[max (n, m)];
        return 0;
    }
    a = n * m;
    b += a;
    while (true){
    	g.clear();
   		for (int i = 1; i <= sqrt (a); i++){
   			if (a % i == 0){
   				g.pb (i);
				if (a / i != i){
					g.pb (a / i);
				}	
			}
		}
		sort (all (g));
    	if (g.size() == 1){
//    		b += n * m;
    		break;
		}
		if (g.size() == 2){
			a--;
		}
		else{
			a = g[g.size() - 2];
		}
		b += n / a * a * m;
	}
	cout << b;
}