#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int x,y;
	cin >> x >> y;
	int sum = 0;
	sum += x + y;
	int a = max(x,y);
	int b = min(x,y);
	while(b != 0){
		a = a % b;
		int c = a;
		a = b;
		b = c;
	}
	cout << sum - a + 1 << endl;
	return 0;
} 
