#include <bits/stdc++.h>

using namespace std;

int main() {
	int x, y, sum;

	cin >> x >> y;
	sum = x + 1;
	for (int i = 1; i < y; ++i) {
		if ((x*i) % y != 0) {
			++sum;
		}
	}
	cout << sum << endl;
	
	return 0;
}
