#include <iostream>
#include <cmath>
using namespace std;
const double EPS = 1e-8;

int main(){
	int x,y;
	cin >> x >> y;
	double m = (double)y/x;
	int count = 0;
	for(int i=0; i<=x; i++){
		if(abs(m*i -round(m*i)) < EPS){
			count++;
		}
	}
	cout << x+y+2-count << endl;
	return 0;
}

