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

int main()
{
	int x, y, i, a, b, c;
	cin >> x >> y;
	a = max(x, y);
	for (i = a; i > 0; i--) {
		if (x%i == 0 && y%i == 0) {
			b = i;
			break;
		}
	}
	c = 1 + x + y - b;
	cout << c << endl;
	return 0;
}

